public class PropertyFactory extends Object
org.apache.cayenne.exp.property
Modifier and Type | Field and Description |
---|---|
static NumericProperty<Long> |
COUNT
Property that can be used to select
COUNT(*) |
static DateProperty<LocalDateTime> |
NOW
Property that corresponds to SQL function
NOW() |
Constructor and Description |
---|
PropertyFactory() |
Modifier and Type | Method and Description |
---|---|
static <T> BaseProperty<T> |
createBase(Expression expression,
Class<T> type)
Create base property
|
static <T> BaseProperty<T> |
createBase(String name,
Class<T> type)
Create base property
|
static <T> BaseProperty<T> |
createBase(String name,
Expression expression,
Class<T> type)
Create base property
|
static <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(Expression expression,
Class<T> type)
Create date property
|
static <T> DateProperty<T> |
createDate(String name,
Class<T> type)
Create date property
|
static <T> DateProperty<T> |
createDate(String name,
Expression expression,
Class<T> type)
Create date property
|
static <T extends EmbeddableObject> |
createEmbeddable(String name,
Class<T> embeddableType)
Create property that represents embeddable
|
static <T extends EmbeddableObject> |
createEmbeddable(String name,
Expression exp,
Class<T> embeddableType)
Create property that represents embeddable
|
static <T extends Persistent> |
createEntity(Expression expression,
Class<T> type)
Create entity property
|
static <T extends Persistent> |
createEntity(String name,
Class<T> type)
Create entity property
|
static <T extends Persistent> |
createEntity(String name,
Expression expression,
Class<T> entityType)
Create entity property
|
static <T extends Persistent> |
createList(String name,
Class<T> entityType)
Create to-many relationship mapped on list property
|
static <T extends Persistent> |
createList(String name,
Expression expression,
Class<T> entityType)
Create to-many relationship mapped on list property
|
static <K,V extends Persistent> |
createMap(String name,
Class<K> keyType,
Class<V> entityType)
Create to-many relationship mapped on map property
|
static <K,V extends Persistent> |
createMap(String name,
Expression expression,
Class<K> keyType,
Class<V> entityType)
Create to-many relationship mapped on map property
|
static <T extends Number> |
createNumeric(Expression expression,
Class<T> type)
Create numeric property
|
static <T extends Number> |
createNumeric(String name,
Class<T> type)
Create numeric property
|
static <T extends Number> |
createNumeric(String name,
Expression expression,
Class<T> type)
Create numeric property
|
static <T extends Number> |
createNumericId(String attribute,
String entityName,
Class<T> propertyType) |
static <T extends Number> |
createNumericId(String attribute,
String path,
String entityName,
Class<T> propertyType) |
static <T extends Persistent> |
createSelf(Class<T> type)
Self property allows to create column queries that return
full objects along with custom column set.
|
static <T extends Persistent> |
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> |
createSet(String name,
Class<T> entityType)
Create to-many relationship mapped on set property
|
static <T extends Persistent> |
createSet(String name,
Expression expression,
Class<T> entityType)
Create to-many relationship mapped on set property
|
static <T extends CharSequence> |
createString(Expression expression,
Class<T> type)
Create string property
|
static <T extends CharSequence> |
createString(String name,
Class<T> type)
Create string property
|
static <T extends CharSequence> |
createString(String name,
Expression expression,
Class<T> type)
Create string property
|
public static final NumericProperty<Long> COUNT
COUNT(*)
Usage:
ObjectSelect.columnQuery(Artist.class, Artist.ARTIST_NAME, PropertyFactory.COUNT);
ObjectSelect.selectCount(ObjectContext)
public static final DateProperty<LocalDateTime> NOW
NOW()
Usage:
ObjectSelect.query(Artist.class).where(Artist.DATE_OF_BIRTH.year().lt(PropertyFactory.NOW.year().sub(100)));
public static <T> BaseProperty<T> createBase(String name, Expression expression, Class<T> type)
T
- type of represented attributename
- of the propertyexpression
- that property will usetype
- type of represented attributepublic static <T> BaseProperty<T> createBase(String name, Class<T> type)
T
- type of represented attributename
- of the property, will be used as value for path expressiontype
- type of represented attributepublic static <T> BaseProperty<T> createBase(Expression expression, Class<T> type)
T
- type of represented attributeexpression
- that property will usetype
- type of represented attributepublic static <T extends CharSequence> StringProperty<T> createString(String name, Expression expression, Class<T> type)
T
- type of represented attributename
- of the propertyexpression
- that property will usetype
- type of represented attributepublic static <T extends CharSequence> StringProperty<T> createString(String name, Class<T> type)
T
- type of represented attributename
- of the property, will be used as value for path expressiontype
- type of represented attributepublic static <T extends CharSequence> StringProperty<T> createString(Expression expression, Class<T> type)
T
- type of represented attributeexpression
- that property will usetype
- type of represented attributepublic static <T extends Number> NumericProperty<T> createNumeric(String name, Expression expression, Class<T> type)
T
- type of represented attributename
- of the propertyexpression
- that property will usetype
- type of represented attributepublic static <T extends Number> NumericProperty<T> createNumeric(String name, Class<T> type)
T
- type of represented attributename
- of the property, will be used as value for path expressiontype
- type of represented attributepublic static <T extends Number> NumericProperty<T> createNumeric(Expression expression, Class<T> type)
T
- type of represented attributeexpression
- that property will usetype
- type of represented attributepublic static <T> DateProperty<T> createDate(String name, Expression expression, Class<T> type)
T
- type of represented attributename
- of the propertyexpression
- that property will usetype
- type of represented attributepublic static <T> DateProperty<T> createDate(String name, Class<T> type)
T
- type of represented attributename
- of the property, will be used as value for path expressiontype
- type of represented attributepublic static <T> DateProperty<T> createDate(Expression expression, Class<T> type)
T
- type of represented attributeexpression
- that property will usetype
- type of represented attributepublic static <T extends Persistent> EntityProperty<T> createEntity(String name, Expression expression, Class<T> entityType)
T
- type of represented relationship entityname
- of the propertyexpression
- that property will useentityType
- type of represented relationship entitypublic static <T extends Persistent> EntityProperty<T> createEntity(String name, Class<T> type)
T
- type of represented relationship entityname
- of the property, will be used as value for path expressiontype
- type of represented relationship entitypublic static <T extends Persistent> EntityProperty<T> createEntity(Expression expression, Class<T> type)
T
- type of represented relationship entityexpression
- that property will usetype
- type of represented relationship entitypublic static <T extends Persistent> EntityProperty<T> createSelf(Class<T> type)
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);
T
- type of represented entitytype
- of represented entitypublic static <T extends Persistent> EntityProperty<T> createSelf(Expression expression, Class<T> type)
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);
T
- type of represented entityexpression
- expression to be used for this property (usually it will be path from other property)type
- of represented entitypublic static <T extends Persistent> ListProperty<T> createList(String name, Expression expression, Class<T> entityType)
T
- type of represented relationship entityname
- of the propertyexpression
- that property will useentityType
- type of represented relationship entitypublic static <T extends Persistent> ListProperty<T> createList(String name, Class<T> entityType)
T
- type of represented relationship entityname
- of the property, will be used as value for path expressionentityType
- type of represented relationship entitypublic static <T extends Persistent> SetProperty<T> createSet(String name, Expression expression, Class<T> entityType)
T
- type of represented attributename
- of the propertyexpression
- that property will useentityType
- type of represented attributepublic static <T extends Persistent> SetProperty<T> createSet(String name, Class<T> entityType)
T
- type of represented relationship entityname
- of the property, will be used as value for path expressionentityType
- type of represented relationship entitypublic static <K,V extends Persistent> MapProperty<K,V> createMap(String name, Expression expression, Class<K> keyType, Class<V> entityType)
K
- type of represented relationship keysV
- type of represented relationship valuesname
- of the propertyexpression
- that property will usekeyType
- type of represented relationship keysentityType
- type of represented relationship valuespublic static <K,V extends Persistent> MapProperty<K,V> createMap(String name, Class<K> keyType, Class<V> entityType)
K
- type of represented relationship keysV
- type of represented relationship valuesname
- of the property, will be used as value for path expressionkeyType
- type of represented relationship keysentityType
- type of represented relationship valuespublic static <T extends EmbeddableObject> EmbeddableProperty<T> createEmbeddable(String name, Class<T> embeddableType)
T
- type of represented embeddable entityname
- of the property, will be used as value for path expressionembeddableType
- type of represented embeddable entitypublic static <T extends EmbeddableObject> EmbeddableProperty<T> createEmbeddable(String name, Expression exp, Class<T> embeddableType)
T
- type of represented embeddable entityname
- of the property, will be used as value for path expressionexp
- that property will useembeddableType
- type of represented embeddable entitypublic static <T> BaseIdProperty<T> createBaseId(String attribute, String entityName, Class<T> propertyType)
public static <T> BaseIdProperty<T> createBaseId(String attribute, String path, String entityName, Class<T> propertyType)
public static <T extends Number> NumericIdProperty<T> createNumericId(String attribute, String entityName, Class<T> propertyType)
Copyright © 2001–2020 Apache Cayenne. All rights reserved.