[Hibernate-JIRA] Created: (ANN-506) Request for Expression Language (EL) for Validator annotations
by Chris Hansen (JIRA)
Request for Expression Language (EL) for Validator annotations
--------------------------------------------------------------
Key: ANN-506
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-506
Project: Hibernate Annotations
Type: New Feature
Components: validator
Environment: All
Reporter: Chris Hansen
Since annotations are limited to primitive types, I would like to see a type of EL for the Validator annotations (similar to the JSF/JSP EL). This would effectively overcome this limitation of annotations and allow for very powerful functionality, such as utilizing the natural ordering of classes. For example:
@Range(min="#{MyClass.MIN_OBJECT}", max="#{MyClass.MAX_OBJECT}") public MyClass getCurrent()
Assuming MIN_OBJECT and MAX_OBJECT are (static, final) instances of MyClass and MyClass implements Comparable<myClass>, the validator could compare the return value of the method with both MIN_OBJECT and MAX_OBJECT and validate that it is within the desired range.
This is just an example. I'm sure there are many more interesting uses possible because this is a powerful concept.
The regular functionality of the annotatinos could be preserved by treating static (non-EL) values, such as the string "0", as old-style primitives, e.g. @Min(value="0").
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
17 years, 5 months
[Hibernate-JIRA] Created: (ANN-617) NullPointerException when handling @OrderBy
by Jifeng Liu (JIRA)
NullPointerException when handling @OrderBy
-------------------------------------------
Key: ANN-617
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-617
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.0.ga
Environment: Hibernate Core 3.2.4.SP1; Hibernate Annotations 3.3.0 GA; Hibernate EntityManager 3.3.1 GA; Oracle OC4J; Oracle DB 10g
Reporter: Jifeng Liu
After I updated from Hibernate Annotations 3.2.1ga to 3.3.0ga, I get the following NullPointerException:
Caused by: java.lang.NullPointerException
at org.hibernate.cfg.annotations.CollectionBinder.buildOrderByClauseFromHql(CollectionBinder.java:851)
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1133)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:576)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1269)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:150)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:416)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:138)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:114)
at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:175)
After I debug it, the variable 'pc' is null in the CollectionBinder.java:851 line:
table = pc.getTable().getQuotedName() + ".";
It seems like this bug is introduced by fix of ANN-516 '@OrderBy added to wrong table in inheritance relationship'.
The related persist classes are:
// ------ The class with @OrderBy annotation
@Entity
@Table(name="RG_SECTION")
@IdClass(SectionID.class)
public class Section extends AbstractSection{
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name="V_Current_Section_Term",
joinColumns= {
@JoinColumn(name="Section_School_Id", referencedColumnName="School_Id"),
@JoinColumn(name="Section_ID", referencedColumnName="Section_ID")},
inverseJoinColumns= {
@JoinColumn(name="Term_School_Id", referencedColumnName="School_Id"),
@JoinColumn(name="Term_Academic_Yr", referencedColumnName="Academic_Yr"),
@JoinColumn(name="Term_Sort_No",referencedColumnName="Term_Sort_No")}
)
@OrderBy("termSortNo")
public List<Term> getTerms() {
return super.getTerms();
}
// -------------- This Entity class in the Collection ---------
@Entity
@Table(name="SCHOOL_TERMS")
@IdClass(TermID.class)
public class Term extends AbstractBusinessObject implements Comparable{
....
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 5 months
[Hibernate-JIRA] Created: (ANN-608) NullPointerException from AnnotationConfiguration with specific order of calling addResource and addPackage when package-info.java present
by Steve Gilbert (JIRA)
NullPointerException from AnnotationConfiguration with specific order of calling addResource and addPackage when package-info.java present
------------------------------------------------------------------------------------------------------------------------------------------
Key: ANN-608
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-608
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Environment: Hibernate 3.2.3
Reporter: Steve Gilbert
Attachments: Main.java, orm.xml, package-info.java
There is a bug in AnnotationConfiguration that causes a NullPointerException.
I have attached several files: orm.xml, Main.java, package-info.java.
The problem is caused by the order of the addResource and addPackage calls in combination with having a package-info.java file with some contents. If the addPackage is called before the addResource, or if the GenericGenerator annotation in the package info file is removed, there is no problem.
I cannot change the order of those calls for my production code, however, because Spring is being used to create the SessionFactory and it calls the methods in that order: resource followed by package.
There appears to be a problem with initializing
org.hibernate.cfg.annotations.reflection.EJB3OverridenAnnotationReader. When this call is made on line 360:
annotationsMap.put( ann.annotationType(), ann );
the map is null. Inserting a creation for the map, (borrowed from elsewhere in the method) on line 359, before the "for" statement:
annotationsMap = new HashMap<Class, Annotation>( annotations.length + 5 );
resolves the problem.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 5 months
[Hibernate-JIRA] Created: (ANN-602) SecondaryTable with EmbeddedId and IdClass is broken
by Chandra (JIRA)
SecondaryTable with EmbeddedId and IdClass is broken
----------------------------------------------------
Key: ANN-602
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-602
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.0.ga
Environment: Hibernate Core 3.2.3 GA
Hibernate Annotations 3.3.0.GA
hibernate-entitymanager-3.3.1.GA
Reporter: Chandra
Attachments: CompositeIdTest.java, TvProgram.java, TvProgramIdClass.java
I added following two classes (TvProgram and TvProgramIdClass) in org.hibernate.test.annotations.cid package. And added two test cases to org.hibernate.test.annotations.cid.CompositeIdTest. See testSecondaryTableWithCompositeId and testSecondaryTableWithIdClass methods in attached fi
The test cases fail with following output. However, if I remove SecondaryTable and secondary table @Column, test cases pass.
12:43:15,534 INFO Version:15 - Hibernate Annotations 3.3.0.GA
12:43:15,550 INFO Environment:509 - Hibernate 3.2.3
12:43:15,565 INFO Environment:527 - loaded properties from resource hibernate.properties: {hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.cache.region_prefix=hibernate.test, hibernate.proxool.pool_alias=pool1, hibernate.bytecode.use_reflection_optimizer=false, hibernate.default_batch_fetch_size=100, hibernate.cache.use_query_cache=true, hibernate.jdbc.use_streams_for_binary=true, hibernate.max_fetch_depth=1, hibernate.format_sql=true, hibernate.connection.pool_size=1, hibernate.connection.username=sa, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.order_updates=true, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:.}
12:43:15,565 INFO Environment:558 - using java.io streams to persist binary types
12:43:15,581 INFO Environment:676 - Bytecode provider name : cglib
12:43:15,581 INFO Environment:593 - using JDK 1.4 java.sql.Timestamp handling
12:43:15,675 INFO Dialect:152 - Using dialect: org.hibernate.dialect.HSQLDialect
12:43:15,815 INFO AnnotationBinder:398 - Binding entity from annotated class: org.hibernate.test.annotations.cid.Parent
12:43:15,862 INFO EntityBinder:420 - Bind entity org.hibernate.test.annotations.cid.Parent on table Parent
12:43:15,894 INFO AnnotationBinder:398 - Binding entity from annotated class: org.hibernate.test.annotations.cid.Child
12:43:15,909 INFO EntityBinder:420 - Bind entity org.hibernate.test.annotations.cid.Child on table Child
12:43:15,925 INFO AnnotationBinder:398 - Binding entity from annotated class: org.hibernate.test.annotations.cid.Channel
12:43:15,925 INFO EntityBinder:420 - Bind entity org.hibernate.test.annotations.cid.Channel on table Channel
12:43:15,941 INFO AnnotationBinder:398 - Binding entity from annotated class: org.hibernate.test.annotations.cid.TvMagazin
12:43:15,941 INFO EntityBinder:420 - Bind entity org.hibernate.test.annotations.cid.TvMagazin on table TvMagazin
12:43:15,941 INFO AnnotationBinder:398 - Binding entity from annotated class: org.hibernate.test.annotations.cid.TvProgramIdClass
12:43:15,941 INFO EntityBinder:420 - Bind entity org.hibernate.test.annotations.cid.TvProgramIdClass on table TvProgramIdClass
12:43:15,956 INFO EntityBinder:631 - Adding secondary table to entity org.hibernate.test.annotations.cid.TvProgramIdClass -> TV_PROGRAM_IDCLASS
java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:427)
at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:53)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:210)
at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:483)
at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:440)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.test.annotations.TestCase.buildSessionFactory(TestCase.java:51)
at org.hibernate.test.annotations.TestCase.setUp(TestCase.java:61)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:65)
at junit.textui.TestRunner.doRun(TestRunner.java:109)
at com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:24)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:427)
at org.hibernate.util.JoinedIterator.next(JoinedIterator.java:53)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:210)
at org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:483)
at org.hibernate.cfg.annotations.EntityBinder.finalSecondaryTableBinding(EntityBinder.java:440)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.test.annotations.TestCase.buildSessionFactory(TestCase.java:51)
at org.hibernate.test.annotations.TestCase.setUp(TestCase.java:61)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
17 years, 5 months