/** * Creates a simple property type used for mapping basic types such as String, long, integer etc. * * @param owner The owner * @param context The MappingContext * @param pd The PropertyDescriptor * @return A Simple property type */ public Simple<T> createSimple(PersistentEntity owner, MappingContext context, PropertyDescriptor pd) { return new Simple<T>(owner, context, pd) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping<T> getMapping() { return propertyMapping; } }; }
/** * Creates an identifier property * * @param owner The owner * @param context The context * @param pd The PropertyDescriptor * @return An Identity instance */ public Identity<T> createIdentity(PersistentEntity owner, MappingContext context, PropertyDescriptor pd) { return new Identity<T>(owner, context, pd) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping<T> getMapping() { return propertyMapping; } }; }
/** * Creates a many-to-one association type used for a mapping a many-to-one association between entities * * @param entity The entity * @param context The context * @param property The property * @return The ToOne instance */ public ToOne createManyToOne(PersistentEntity entity, MappingContext context, PropertyDescriptor property) { return new ManyToOne<T>(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping getMapping() { return propertyMapping; } @Override public String toString() { return associationtoString("many-to-one: ", this); } }; }
/** * Creates an {@link Embedded} type used to model an embedded association (composition) * * @param entity The entity * @param context The context * @param property The property * @return The {@link Embedded} instance */ public Embedded createEmbedded(PersistentEntity entity, MappingContext context, PropertyDescriptor property) { return new Embedded<T>(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping getMapping() { return propertyMapping; } @Override public String toString() { return associationtoString("embedded: ", this); } }; }
/** * Creates a one-to-one association type used for mapping a one-to-one association between entities * * @param entity The entity * @param context The context * @param property The property * @return The ToOne instance */ public ToOne createOneToOne(PersistentEntity entity, MappingContext context, PropertyDescriptor property) { return new OneToOne<T>(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping getMapping() { return propertyMapping; } @Override public String toString() { return associationtoString("one-to-one: ", this); } }; }
/** * Creates a {@link OneToMany} type used to model a one-to-many association between entities * * @param entity The entity * @param context The context * @param property The property * @return The {@link OneToMany} instance */ public OneToMany createOneToMany(PersistentEntity entity, MappingContext context, PropertyDescriptor property) { return new OneToMany<T>(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping getMapping() { return propertyMapping; } @Override public String toString() { return associationtoString("one-to-many: ", this); } }; }
/** * Creates a {@link ManyToMany} type used to model a many-to-many association between entities * * @param entity The entity * @param context The context * @param property The property * @return The {@link ManyToMany} instance */ public ManyToMany createManyToMany(PersistentEntity entity, MappingContext context, PropertyDescriptor property) { return new ManyToMany<T>(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping getMapping() { return propertyMapping; } @Override public String toString() { return associationtoString("many-to-many: ", this); } }; }
/** * Creates an {@link EmbeddedCollection} type used to model an embedded collection association (composition). * * @param entity The entity * @param context The context * @param property The property * @return The {@link Embedded} instance */ public EmbeddedCollection createEmbeddedCollection(PersistentEntity entity, MappingContext context, PropertyDescriptor property) { return new EmbeddedCollection<T>(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping getMapping() { return propertyMapping; } @Override public String toString() { return associationtoString("embedded: ", this); } }; }
/** * Creates a custom prpoerty type * * @param owner The owner * @param context The context * @param pd The PropertyDescriptor * @return A custom property type */ public Custom<T> createCustom(PersistentEntity owner, MappingContext context, PropertyDescriptor pd) { final Class<?> propertyType = pd.getPropertyType(); CustomTypeMarshaller customTypeMarshaller = findCustomType(context, propertyType); if (customTypeMarshaller == null && propertyType.isEnum()) { // If there is no custom type marshaller for current enum, lookup marshaller for enum itself. customTypeMarshaller = findCustomType(context, Enum.class); } if (customTypeMarshaller == null && !allowArbitraryCustomTypes()) { throw new IllegalStateException("Cannot create a custom type without a type converter for type " + propertyType); } return new Custom<T>(owner, context, pd, customTypeMarshaller) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner); public PropertyMapping<T> getMapping() { return propertyMapping; } }; }
MappingContext context, PropertyDescriptor property, Class collectionType) { Basic basic = new Basic(entity, context, property) { PropertyMapping<T> propertyMapping = createPropertyMapping(this, owner);