org.hibernate.annotations.Formula Java Examples
The following examples show how to use
org.hibernate.annotations.Formula.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FormulaTest.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Formula(""" round( (interestRate::numeric / 100) * cents * date_part('month', age(now(), createdOn) ) / 12) """)
Example #2
Source File: FormulaTest.java From high-performance-java-persistence with Apache License 2.0 | 5 votes |
@Formula(""" round( (interestRate::numeric / 100) * cents * date_part('month', age(now(), createdOn) ) / 12) / 100::numeric """)
Example #3
Source File: ColumnsBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
public ColumnsBuilder extractMetadata() { columns = null; joinColumns = buildExplicitJoinColumns(property, inferredData); if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( Formula.class ) ) { Column ann = property.getAnnotation( Column.class ); Formula formulaAnn = property.getAnnotation( Formula.class ); columns = Ejb3Column.buildColumnFromAnnotation( new Column[] { ann }, formulaAnn, nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), buildingContext ); } else if ( property.isAnnotationPresent( Columns.class ) ) { Columns anns = property.getAnnotation( Columns.class ); columns = Ejb3Column.buildColumnFromAnnotation( anns.columns(), null, nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), buildingContext ); } //set default values if needed if ( joinColumns == null && ( property.isAnnotationPresent( ManyToOne.class ) || property.isAnnotationPresent( OneToOne.class ) ) ) { joinColumns = buildDefaultJoinColumnsForXToOne(property, inferredData); } else if ( joinColumns == null && ( property.isAnnotationPresent( OneToMany.class ) || property.isAnnotationPresent( ElementCollection.class ) ) ) { OneToMany oneToMany = property.getAnnotation( OneToMany.class ); String mappedBy = oneToMany != null ? oneToMany.mappedBy() : ""; joinColumns = Ejb3JoinColumn.buildJoinColumns( null, mappedBy, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), buildingContext ); } else if ( joinColumns == null && property.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) { throw new AnnotationException( "@Any requires an explicit @JoinColumn(s): " + BinderHelper.getPath( propertyHolder, inferredData ) ); } if ( columns == null && !property.isAnnotationPresent( ManyToMany.class ) ) { //useful for collection of embedded elements columns = Ejb3Column.buildColumnFromAnnotation( null, null, nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), buildingContext ); } if ( nullability == Nullability.FORCED_NOT_NULL ) { //force columns to not null for (Ejb3Column col : columns ) { col.forceNotNull(); } } return this; }
Example #4
Source File: SurveyDirectory.java From DWSurvey with GNU Affero General Public License v3.0 | 4 votes |
@Formula("(select o.name from t_user o where o.id = user_id)") public String getUserName() { return userName; }
Example #5
Source File: QuestionBank.java From DWSurvey with GNU Affero General Public License v3.0 | 4 votes |
@Formula("(select o.name from t_user o where o.id = user_id)") public String getUserName() { return userName; }