[Hibernate-JIRA] Created: (ANN-480) Query by Example in annotation form
by M N G (JIRA)
Query by Example in annotation form
-----------------------------------
Key: ANN-480
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-480
Project: Hibernate Annotations
Type: New Feature
Environment: jdk >= 1.5, hibernate >= 3, ant > 1.5
Reporter: M N G
Priority: Minor
Attachments: searchable.tar.gz
Interested in adsorbing this framework I built?
Takes all the work out of creating a Criteria. Similar to how Query by Example, this small framework I wrote builds Criteria from annotated pojos.
A pojo is annotated to map hibernate bean mappings to methods. The annotated pojo's class is registered in the Registry, which uses reflecting to define the signatures to create the Criteria for the pojo. The values to search for are set in the pojo and the pojo is passed to the Builder. The Builder uses the registry to create the Criteria delimited by the values in the annotated pojo.
Not entirely mature yet (does not support all Criteria Restrictions) and the handling of sorting results is a bit unwieldy. It works tho.
Attached is a copy of the framework. It includes a unit test that kick starts a HSQL database to demostrate the framework.
--
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
18 years, 9 months
[Hibernate-JIRA] Created: (ANN-526) Property xyz has an unbound type - is that so?
by Sebastian Kirsch (JIRA)
Property xyz has an unbound type - is that so?
----------------------------------------------
Key: ANN-526
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-526
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.1
Reporter: Sebastian Kirsch
Priority: Minor
Attachments: Hibernate ANN-526.zip
I get this "Property reference has an unbound type and no explictit target entity" exception and I think this is not exactly true. I'm not sure if this is a bug or a feature requests though.
Have a look at the attached files and read on.
I guess the model ist pretty easy to understand. The AbstractGeneric allows my to have concrete entities referring to specifc other subclasses - as seen in ConcreteOther and ConcreteSelf. The test case "workingClasses" shows us that Hibernate may work with this model - note that the class AbstractGeneric itslef was NOT added to the configuration.
Now for the problem: The class OtherEntity is a completly different entity, but it refers to instances of AbstractGeneric - to any subclass of it actually, as AbstractGeneric is obviously abstract.
If you run the test case "otherClass" the first part states that Hibernate doesn't know AbstractGeneric - which is fine, so I add that class to the configuration and try to build a session factory again. Now we receive the beforementioned exception.
That's the situation. So is AbstractGeneric really an unbound type? I'd say it is not - T has an upper bound which should be good enough to work with - we know the table and the PK...
--
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
18 years, 9 months
[Hibernate-JIRA] Created: (ANN-596) ManyToMany with CascadeType ALL => StaleStateException
by Steven Morrison (JIRA)
ManyToMany with CascadeType ALL => StaleStateException
------------------------------------------------------
Key: ANN-596
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-596
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga, 3.2.0.cr2
Environment: Hibernate 3.2.0cr2 with Annotations 3.2.0.cr2; and Hibernate 3.2 with Annotations 3.3.0ga.
Spring 2.0.4
HSQL 1.8.0 and MySQL 5.0
Reporter: Steven Morrison
Priority: Minor
Attachments: HibernateManyToManyMappingError.zip
Originally posted as bug to forums (http://forum.hibernate.org/posting.php?mode=editpost&p=2345494), but received no response.
[b]Description:[/b] Hibernate appears to be end up in an inconsistent state when working with a many-to-many mapping using cascade = ALL.
The test below shows Hibernate persisting a Root (with a Value mapped as many-to-many), then later deleting the Root (which also deletes the Value). When attempting to delete the Value, hibernate's "listing entities" logging suggests that the Value instance is still persisted, but the Root deletion has removed this. StaleStateException is then thrown.
[b]Hibernate version:[/b] 3.2
[b]Annotated classes:[/b]
[code]
@Entity
public class RootOfManyToMany
{
@Id
@GeneratedValue( generator = "hibseq" )
@GenericGenerator( name = "hibseq", strategy = "hilo" )
public Long id;
@ManyToMany( fetch = FetchType.EAGER, cascade = javax.persistence.CascadeType.ALL )
@JoinTable(
name = "MAPPING_TABLE",
joinColumns = {@JoinColumn(name = "ROOT_ID")},
inverseJoinColumns = {@JoinColumn(name = "VALUE_ID")}
)
public List< ValueOfManyToMany > values;
}
[/code]
[code]
@Entity
public class ValueOfManyToMany
{
@Id
@GeneratedValue( generator="hibseq" )
@GenericGenerator( name="hibseq", strategy="hilo" )
public Long id;
}
[/code]
Spring config:
[code]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<!-- HSQL for local tests -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName"> <value>org.hsqldb.jdbcDriver</value> </property>
<property name="username"> <value>sa</value> </property>
<property name="password"> <value></value> </property>
<property name="maxActive"> <value>2</value> </property>
<property name="poolPreparedStatements"> <value>false</value> </property>
<property name="url" value="jdbc:hsqldb:mem:test"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show.sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>RootOfManyToMany</value>
<value>ValueOfManyToMany</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<constructor-arg ref="sessionFactory"/>
</bean>
</beans>
[/code]
[b]Code between sessionFactory.openSession() and session.close():[/b]
[code]
public void test_manyToManyRelationship() throws Exception
{
RootOfManyToMany rootOfManyToMany = new RootOfManyToMany();
rootOfManyToMany.values = new ArrayList<ValueOfManyToMany>();
rootOfManyToMany.values.add( new ValueOfManyToMany() );
assertEquals( 0, hibernateTemplate.find( "from RootOfManyToMany" ).size() );
Long id = (Long)hibernateTemplate.save( rootOfManyToMany );
hibernateTemplate.flush();
assertEquals( 1, hibernateTemplate.find( "from RootOfManyToMany" ).size() );
RootOfManyToMany root = (RootOfManyToMany)hibernateTemplate.get( RootOfManyToMany.class, id );
ValueOfManyToMany value = root.values.get( 0 );
hibernateTemplate.delete( root );
hibernateTemplate.flush();
hibernateTemplate.delete( value ); //Exception thrown here
}
[/code]
[b]Full stack trace of any exception that occurs:[/b]
org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:388)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:363)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:774)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:770)
at RootOfManyToManyTest.test_manyToManyRelationship(RootOfManyToManyTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
[b]Name and version of the database you are using:[/b]
HSQL 1.8.0.2
[b]The generated SQL (notable log entries with <returned values>:[/b]
[code]
select rootofmany0_.id as id4_ from ROOT_OF_MANY_TO_MANY rootofmany0_
<returns empty list>
insert into ROOT_OF_MANY_TO_MANY (id) values (?)
binding '1' to parameter: 1
insert into VALUE_OF_MANY_TO_MANY (id) values (?)
binding '32768' to parameter: 1
insert into MAPPING_TABLE (ROOT_ID, VALUE_ID) values (?, ?)
binding '1' to parameter: 1
binding '32768' to parameter: 2
listing entities:
RootOfManyToMany{values=[ValueOfManyToMany#32768], id=1}
ValueOfManyToMany{id=32768}
<returns id=1>
select rootofmany0_.id as id4_ from ROOT_OF_MANY_TO_MANY rootofmany0_
result set row: 0
returning '1' as column: id4_
select values0_.ROOT_ID as ROOT1_1_, values0_.VALUE_ID as VALUE2_1_, valueofman1_.id as id5_0_ from MAPPING_TABLE values0_ left outer join VALUE_OF_MANY_TO_MANY valueofman1_ on values0_.VALUE_ID=valueofman1_.id where values0_.ROOT_ID=?
returning '1' as column: ROOT1_1_
returning '32768' as column: VALUE2_1_
done processing result set (1 rows)
<returns singleton list>
select rootofmany0_.id as id4_1_, values1_.ROOT_ID as ROOT1_3_, valueofman2_.id as VALUE2_3_, valueofman2_.id as id5_0_ from ROOT_OF_MANY_TO_MANY rootofmany0_ left outer join MAPPING_TABLE values1_ on rootofmany0_.id=values1_.ROOT_ID left outer join VALUE_OF_MANY_TO_MANY valueofman2_ on values1_.VALUE_ID=valueofman2_.id where rootofmany0_.id=?
binding '1' to parameter: 1
returning '1' as column: ROOT1_3_
returning '32768' as column: VALUE2_3_
done processing result set (1 rows)
<returns previously persisted root>
delete from MAPPING_TABLE where ROOT_ID=?
binding '1' to parameter: 1
delete from VALUE_OF_MANY_TO_MANY where id=?
binding '32768' to parameter: 1
delete from ROOT_OF_MANY_TO_MANY where id=?
binding '1' to parameter: 1
listing entities:
ValueOfManyToMany{id=32768}
<deletes all DB content including ValueOfManyToMany instance>
delete from VALUE_OF_MANY_TO_MANY where id=?
binding '32768' to parameter: 1
<throws exception>
[/code]
[b]Debug level Hibernate log excerpt:[/b]
Cropped to the tail of first delete:
[code]
DEBUG: Flushed: 0 insertions, 0 updates, 1 deletions to 1 objects
DEBUG: Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG: listing entities:
DEBUG: ValueOfManyToMany{id=32768}
DEBUG: executing flush
DEBUG: registering flush begin
DEBUG: Deleting entity: [ValueOfManyToMany#32768]
DEBUG: about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG: opening JDBC connection
DEBUG: delete from ValueOfManyToMany where id=?
DEBUG: preparing statement
DEBUG: binding '32768' to parameter: 1
DEBUG: Adding to batch
DEBUG: Executing batch size: 1
ERROR: Exception executing batch:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:388)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:363)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:774)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:770)
at RootOfManyToManyTest.test_manyToManyRelationship(RootOfManyToManyTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
DEBUG: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG: closing statement
ERROR: Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:388)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:363)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:774)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:770)
at RootOfManyToManyTest.test_manyToManyRelationship(RootOfManyToManyTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
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 org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
DEBUG: registering flush end
DEBUG: closing session
DEBUG: performing cleanup
DEBUG: releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG: after transaction completion
DEBUG: transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
DEBUG: after transaction completion
[/code]
[b]Question:[/b] Is this a bug in Hibernate? My understanding is that Hibernate's state becomes different to that of the DB, though all deletions are explicitly mentioned in DEBUG logging.
--
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
18 years, 9 months
[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
18 years, 9 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
18 years, 9 months
[Hibernate-JIRA] Created: (ANN-434) Confusing error message with @EmbeddedId and @Id
by Patrick Moore (JIRA)
Confusing error message with @EmbeddedId and @Id
------------------------------------------------
Key: ANN-434
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-434
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.0.cr1
Environment: Hibernate 3.2.0.cr2
Reporter: Patrick Moore
trying to create an entity with embeddedid and automatically generated ids. The resulting error message was very confusing and may be a bug as well.
(See below for sample files) Notice the message is that TransPolId doesn't have an @Id property when in fact it does. The problem is 'solved' by removing the @Id in the TransPolId class. This caused a lot of wasted time on my part please fix for the next person!
--------------------------------------------------------------------------------
Some additional debugging notes:
The problem is caused in part because when expanding TransPolId to within AnnotationBinder.processElementAnnotations()
isIdentifierMapper == false so none of the checks looking for this sort of thing execute.
I believe the solution is to change AnnotationBinder.bindId() as follows:
(original):
if ( isComposite ) {
id = fillComponent(
propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
false, entityBinder, isEmbedded, isIdentifierMapper, mappings
);
Component componentId = (Component) id;
componentId.setKey( true );
if ( componentId.getPropertySpan() == 0 ) {
throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
}
}
(changed):
if ( isComposite ) {
id = fillComponent(
propertyHolder, inferredData, isPropertyAnnotated, propertyAccessor,
false, entityBinder, isEmbedded, true, mappings <<<<<<<<<<<<<<< isIdentifierMapper replaced by true
);
Component componentId = (Component) id;
componentId.setKey( true );
if ( componentId.getPropertySpan() == 0 ) {
throw new AnnotationException( componentId.getComponentClassName() + " has no persistent id property" );
}
}
Output:
java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=Cp1252, java.specification.version=1.5, hibernate.show_sql=true, hibernate.connection.pool_size=1}
16:19:01,109 DEBUG [Configuration] Preparing to build session factory with filters : {}
16:19:01,109 DEBUG [AnnotationConfiguration] Execute first pass mapping processing
16:19:01,109 DEBUG [AnnotationConfiguration] Process hbm files
16:19:01,109 DEBUG [AnnotationConfiguration] Process annotated classes
16:19:01,125 INFO [AnnotationBinder] Binding entity from annotated class: com.transparentpolitics.core.persistence.IdUsing1
16:19:01,125 DEBUG [Ejb3Column] Binding column DTYPE unique false
16:19:01,125 DEBUG [EntityBinder] Import with entity name=IdUsing1
16:19:01,125 INFO [EntityBinder] Bind entity com.transparentpolitics.core.persistence.IdUsing1 on table IdUsing1
16:19:01,125 DEBUG [AnnotationBinder] Processing com.transparentpolitics.core.persistence.IdUsing1 property annotation
16:19:01,125 DEBUG [AnnotationBinder] Processing com.transparentpolitics.core.persistence.IdUsing1 field annotation
16:19:01,125 DEBUG [AnnotationBinder] Processing annotations of com.transparentpolitics.core.persistence.IdUsing1.transid
16:19:01,125 DEBUG [Ejb3Column] Binding column transid unique false
16:19:01,125 DEBUG [AnnotationBinder] transid is an id
16:19:01,125 DEBUG [AnnotationBinder] Binding component with path: com.transparentpolitics.core.persistence.IdUsing1.transid
16:19:01,125 DEBUG [AnnotationBinder] Processing com.transparentpolitics.core.persistence.TransPolId field annotation
16:19:01,125 DEBUG [AnnotationBinder] Processing annotations of com.transparentpolitics.core.persistence.TransPolId.id
16:19:01,125 DEBUG [Ejb3Column] Binding column id unique false
16:19:01,125 DEBUG [AnnotationBinder] id is an id
16:19:01,125 DEBUG [SimpleValueBinder] building SimpleValue for id
16:19:01,125 DEBUG [PropertyBinder] Building property id
16:19:01,125 DEBUG [PropertyBinder] Cascading id with null
16:19:01,125 DEBUG [AnnotationBinder] Bind @Id on id
org.hibernate.AnnotationException: com.transparentpolitics.core.persistence.TransPolId has no persistent id property
at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1686)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1170)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:699)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:353)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:265)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:682)
... 20 more
@Embeddable
public class TransPolId implements Serializable {
@Id @GeneratedValue
public Long id;
@Override
public boolean equals(Object o) {
if ( o instanceof TransPolId ) {
return ((TransPolId)o).id.equals(id);
}
return false;
}
@Override
public int hashCode() {
return id.hashCode();
}
}
@Entity
public class IdUsing1 {
@EmbeddedId
public TransPolId id;
public String value;
}
--
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
18 years, 9 months