Package org.apache.cayenne.exp.property
Class PropertyFactory
java.lang.Object
org.apache.cayenne.exp.property.PropertyFactory
Factory class that produces all property types.
- Since:
- 4.2
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final NumericProperty
<Long> Property that can be used to selectCOUNT(*)
static final DateProperty
<LocalDateTime> Property that corresponds to SQL functionNOW()
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BaseProperty
<T> createBase
(String name, Class<T> type) Create base propertystatic <T> BaseProperty
<T> createBase
(String name, Expression expression, Class<T> type) Create base propertystatic <T> BaseProperty
<T> createBase
(Expression expression, Class<T> type) Create base propertystatic <T> BaseIdProperty
<T> createBaseId
(String attribute, String entityName, Class<T> propertyType) static <T> BaseIdProperty
<T> createBaseId
(String attribute, String path, String entityName, Class<T> propertyType) static <T> DateProperty
<T> createDate
(String name, Class<T> type) Create date propertystatic <T> DateProperty
<T> createDate
(String name, Expression expression, Class<T> type) Create date propertystatic <T> DateProperty
<T> createDate
(Expression expression, Class<T> type) Create date propertystatic <T extends EmbeddableObject>
EmbeddableProperty<T> createEmbeddable
(String name, Class<T> embeddableType) Create property that represents embeddablestatic <T extends EmbeddableObject>
EmbeddableProperty<T> createEmbeddable
(String name, Expression exp, Class<T> embeddableType) Create property that represents embeddablestatic <T extends Persistent>
EntityProperty<T> createEntity
(String name, Class<T> type) Create entity propertystatic <T extends Persistent>
EntityProperty<T> createEntity
(String name, Expression expression, Class<T> entityType) Create entity propertystatic <T extends Persistent>
EntityProperty<T> createEntity
(Expression expression, Class<T> type) Create entity propertystatic <T extends Persistent>
ListProperty<T> createList
(String name, Class<T> entityType) Create to-many relationship mapped on list propertystatic <T extends Persistent>
ListProperty<T> createList
(String name, Expression expression, Class<T> entityType) Create to-many relationship mapped on list propertystatic <K,
V extends Persistent>
MapProperty<K, V> Create to-many relationship mapped on map propertystatic <K,
V extends Persistent>
MapProperty<K, V> createMap
(String name, Expression expression, Class<K> keyType, Class<V> entityType) Create to-many relationship mapped on map propertystatic <T extends Number>
NumericProperty<T> createNumeric
(String name, Class<T> type) Create numeric propertystatic <T extends Number>
NumericProperty<T> createNumeric
(String name, Expression expression, Class<T> type) Create numeric propertystatic <T extends Number>
NumericProperty<T> createNumeric
(Expression expression, Class<T> type) Create numeric propertystatic <T extends Number>
NumericIdProperty<T> createNumericId
(String attribute, String entityName, Class<T> propertyType) static <T extends Number>
NumericIdProperty<T> createNumericId
(String attribute, String path, String entityName, Class<T> propertyType) static <T extends Persistent>
EntityProperty<T> createSelf
(Class<T> type) Self property allows to create column queries that return full objects along with custom column set.static <T extends Persistent>
EntityProperty<T> createSelf
(Expression expression, Class<T> type) Self property allows to create column queries that return full objects along with custom column set.static <T extends Persistent>
SetProperty<T> Create to-many relationship mapped on set propertystatic <T extends Persistent>
SetProperty<T> createSet
(String name, Expression expression, Class<T> entityType) Create to-many relationship mapped on set propertystatic <T extends CharSequence>
StringProperty<T> createString
(String name, Class<T> type) Create string propertystatic <T extends CharSequence>
StringProperty<T> createString
(String name, Expression expression, Class<T> type) Create string propertystatic <T extends CharSequence>
StringProperty<T> createString
(Expression expression, Class<T> type) Create string property
-
Field Details
-
COUNT
Property that can be used to selectCOUNT(*)
Usage:
ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME, PropertyFactory.COUNT);
- See Also:
-
NOW
Property that corresponds to SQL functionNOW()
Usage:
ObjectSelect.query(Artist.class).where(Artist.DATE_OF_BIRTH.year().lt(PropertyFactory.NOW.year().sub(100)));
-
-
Constructor Details
-
PropertyFactory
public PropertyFactory()
-
-
Method Details
-
createBase
Create base property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the propertyexpression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression
-
createBase
Create base property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the property, will be used as value for path expressiontype
- type of represented attribute- Returns:
- new path property
-
createBase
Create base property- Type Parameters:
T
- type of represented attribute- Parameters:
expression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression without name
-
createString
public static <T extends CharSequence> StringProperty<T> createString(String name, Expression expression, Class<T> type) Create string property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the propertyexpression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression
-
createString
Create string property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the property, will be used as value for path expressiontype
- type of represented attribute- Returns:
- new path property
-
createString
public static <T extends CharSequence> StringProperty<T> createString(Expression expression, Class<T> type) Create string property- Type Parameters:
T
- type of represented attribute- Parameters:
expression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression without name
-
createNumeric
public static <T extends Number> NumericProperty<T> createNumeric(String name, Expression expression, Class<T> type) Create numeric property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the propertyexpression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression
-
createNumeric
Create numeric property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the property, will be used as value for path expressiontype
- type of represented attribute- Returns:
- new path property
-
createNumeric
public static <T extends Number> NumericProperty<T> createNumeric(Expression expression, Class<T> type) Create numeric property- Type Parameters:
T
- type of represented attribute- Parameters:
expression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression without name
-
createDate
Create date property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the propertyexpression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression
-
createDate
Create date property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the property, will be used as value for path expressiontype
- type of represented attribute- Returns:
- new path property
-
createDate
Create date property- Type Parameters:
T
- type of represented attribute- Parameters:
expression
- that property will usetype
- type of represented attribute- Returns:
- new property with custom expression without name
-
createEntity
public static <T extends Persistent> EntityProperty<T> createEntity(String name, Expression expression, Class<T> entityType) Create entity property- Type Parameters:
T
- type of represented relationship entity- Parameters:
name
- of the propertyexpression
- that property will useentityType
- type of represented relationship entity- Returns:
- new property with custom expression
-
createEntity
Create entity property- Type Parameters:
T
- type of represented relationship entity- Parameters:
name
- of the property, will be used as value for path expressiontype
- type of represented relationship entity- Returns:
- new path property
-
createEntity
public static <T extends Persistent> EntityProperty<T> createEntity(Expression expression, Class<T> type) Create entity property- Type Parameters:
T
- type of represented relationship entity- Parameters:
expression
- that property will usetype
- type of represented relationship entity- Returns:
- new property with custom expression without name
-
createSelf
Self property allows to create column queries that return full objects along with custom column set.Usage example, query will return object with dependent objects count:
List<Object[]> result = ObjectSelect.columnQuery(Artist.class, PropertyFactory.createSelf(Artist.class), Artist.PAINTING_ARRAY.count()) .select(context);
- Type Parameters:
T
- type of represented entity- Parameters:
type
- of represented entity- Returns:
- new 'self' property
-
createSelf
public static <T extends Persistent> EntityProperty<T> createSelf(Expression expression, Class<T> type) Self property allows to create column queries that return full objects along with custom column set.This method is not much useful, as to-one property can be used as is in this case, example is purely for demonstration purpose only. See
EntityProperty
usage examples.Usage example, query will return object with dependent objects count:
List<Object[]> result = ObjectSelect.columnQuery(Painting.class, Painting.PAINTING_TITLE, PropertyFactory.createSelf(Painting.TO_ARTIST.getExpression(), Painting.class)) .select(context);
- Type Parameters:
T
- type of represented entity- Parameters:
expression
- expression to be used for this property (usually it will be path from other property)type
- of represented entity- Returns:
- new 'self' property
-
createList
public static <T extends Persistent> ListProperty<T> createList(String name, Expression expression, Class<T> entityType) Create to-many relationship mapped on list property- Type Parameters:
T
- type of represented relationship entity- Parameters:
name
- of the propertyexpression
- that property will useentityType
- type of represented relationship entity- Returns:
- new property with custom expression
-
createList
Create to-many relationship mapped on list property- Type Parameters:
T
- type of represented relationship entity- Parameters:
name
- of the property, will be used as value for path expressionentityType
- type of represented relationship entity- Returns:
- new path property
-
createSet
public static <T extends Persistent> SetProperty<T> createSet(String name, Expression expression, Class<T> entityType) Create to-many relationship mapped on set property- Type Parameters:
T
- type of represented attribute- Parameters:
name
- of the propertyexpression
- that property will useentityType
- type of represented attribute- Returns:
- new property with custom expression
-
createSet
Create to-many relationship mapped on set property- Type Parameters:
T
- type of represented relationship entity- Parameters:
name
- of the property, will be used as value for path expressionentityType
- type of represented relationship entity- Returns:
- new path property
-
createMap
public static <K,V extends Persistent> MapProperty<K,V> createMap(String name, Expression expression, Class<K> keyType, Class<V> entityType) Create to-many relationship mapped on map property- Type Parameters:
K
- type of represented relationship keysV
- type of represented relationship values- Parameters:
name
- of the propertyexpression
- that property will usekeyType
- type of represented relationship keysentityType
- type of represented relationship values- Returns:
- new property with custom expression
-
createMap
public static <K,V extends Persistent> MapProperty<K,V> createMap(String name, Class<K> keyType, Class<V> entityType) Create to-many relationship mapped on map property- Type Parameters:
K
- type of represented relationship keysV
- type of represented relationship values- Parameters:
name
- of the property, will be used as value for path expressionkeyType
- type of represented relationship keysentityType
- type of represented relationship values- Returns:
- new path property
-
createEmbeddable
public static <T extends EmbeddableObject> EmbeddableProperty<T> createEmbeddable(String name, Class<T> embeddableType) Create property that represents embeddable- Type Parameters:
T
- type of represented embeddable entity- Parameters:
name
- of the property, will be used as value for path expressionembeddableType
- type of represented embeddable entity- Returns:
- new path property
-
createEmbeddable
public static <T extends EmbeddableObject> EmbeddableProperty<T> createEmbeddable(String name, Expression exp, Class<T> embeddableType) Create property that represents embeddable- Type Parameters:
T
- type of represented embeddable entity- Parameters:
name
- of the property, will be used as value for path expressionexp
- that property will useembeddableType
- type of represented embeddable entity- Returns:
- new path property
-
createBaseId
public static <T> BaseIdProperty<T> createBaseId(String attribute, String entityName, Class<T> propertyType) -
createBaseId
public static <T> BaseIdProperty<T> createBaseId(String attribute, String path, String entityName, Class<T> propertyType) -
createNumericId
public static <T extends Number> NumericIdProperty<T> createNumericId(String attribute, String entityName, Class<T> propertyType) -
createNumericId
-