[Hibernate-JIRA] Created: (HHH-7157) Bi-directional Many-to-One and One-to-Many mapping with EmbeddedId fails
by Clement Pang (JIRA)
Bi-directional Many-to-One and One-to-Many mapping with EmbeddedId fails
------------------------------------------------------------------------
Key: HHH-7157
URL: https://hibernate.onjira.com/browse/HHH-7157
Project: Hibernate ORM
Issue Type: Bug
Components: envers
Affects Versions: 4.1.1
Reporter: Clement Pang
Please see attached test cases on git: https://github.com/panghy/envers-embeddedid-test
Hibernate tries to insert a parameter in the Audit table where there isn't one (6 parameter, trying to insert 7 and more). The issue goes away if we add a @NotAudited annotation to the OneToMany side of the relation (commented out in the code).
Hibernate:
insert
into
PersonTuple_AUD
(REVTYPE, helloWorld, personA_id, personB_id, constant_id, REV)
values
(?, ?, ?, ?, ?, ?)
Mar 8, 2012 2:11:39 AM org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release
INFO: HHH000010: On release of batch it still contained JDBC statements
javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:90)
at org.hibernate.clementp.EnversTest.testAuditedEmbeddedId(EnversTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:182)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Invalid value "7" for parameter "parameterIndex" [90008-143]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1360)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1288)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:78)
... 31 more
Caused by: org.hibernate.exception.GenericJDBCException: Invalid value "7" for parameter "parameterIndex" [90008-143]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy22.setLong(Unknown Source)
at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$1.doBind(BigIntTypeDescriptor.java:57)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:305)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:300)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:358)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2611)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2854)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3298)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:275)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1127)
at org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:157)
at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:662)
at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:307)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:524)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:105)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:73)
... 31 more
Caused by: org.h2.jdbc.JdbcSQLException: Invalid value "7" for parameter "parameterIndex" [90008-143]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.getInvalidValueException(DbException.java:213)
at org.h2.jdbc.JdbcPreparedStatement.setParameter(JdbcPreparedStatement.java:1254)
at org.h2.jdbc.JdbcPreparedStatement.setLong(JdbcPreparedStatement.java:541)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 55 more
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-4751) Fix for @embeddedid error: Type not supported: org.hibernate.type.ManyToOneType
by David Coleman (JIRA)
Fix for @embeddedid error: Type not supported: org.hibernate.type.ManyToOneType
--------------------------------------------------------------------------------
Key: HHH-4751
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4751
Project: Hibernate Core
Issue Type: Improvement
Components: envers
Reporter: David Coleman
Priority: Minor
Attachments: IDMetadataGenerator_patch.txt
Hi,
After creating hibernate entities from the legacy database with envers hibernate tool, I noticed the following error occurred on creating an audit tables that has an @EmbeddedId attribute (related to ENVERS-76]:
Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.ManyToOneType ..
I found out by looking at the source that the reason it failed was that the property type was not an instance of ImmutableType (not mutable); which was true as the embedded id was a combination of an int and a mutable java data object. I switched the mutable java date object to a immutable joda datetime object using the joda date time hibernate user type to fix the immutable problem.
I also patched IdMetadataGenerator locally to the one attached as hibernate usertypes do not implement the ImmutableType interface; using the method 'isMutable()' should be suffice.
Let me know if this is okay so I can submit the patch.
--
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
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-7115) Allow types to have access to target usage data
by Michael Nascimento Santos (JIRA)
Allow types to have access to target usage data
-----------------------------------------------
Key: HHH-7115
URL: https://hibernate.onjira.com/browse/HHH-7115
Project: Hibernate ORM
Issue Type: Improvement
Components: core
Affects Versions: 4.1.0
Environment: hibernate-core:4.1.0.Final
Reporter: Michael Nascimento Santos
In order to being able to support a type hierarchy without having to write a Type per class, access to the actual target property type is needed. This has been hardcoded in org.hibernate.cfg.annotations.SimpleValueBinder for some Hibernate types, such as org.hibernate.type.EnumType and org.hibernate.type.SerializableToBlobType.
Even for the same scenarios above, if one is trying to write his own type for enums or serializables, he has to end up writing a type per target class since the same facility is not provided by Hibernate in a general fashion.
Hence, Hibernate should provide a set of standard properties for type implementations that need actual target usage data. Since some types might use the same property names used by EnumType with a different meaning, injecting these properties for any ParameterizedType might break existing types. Therefore, a ParameterizedType subinterface which also declares the standard property names for this case seems a better design choice.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-7300) TypeDefs won't be found depending of files read-order
by Stefan Schulze (JIRA)
TypeDefs won't be found depending of files read-order
-----------------------------------------------------
Key: HHH-7300
URL: https://hibernate.onjira.com/browse/HHH-7300
Project: Hibernate ORM
Issue Type: Bug
Components: metamodel
Affects Versions: 4.1.3, 3.6.10, 4.0.1
Reporter: Stefan Schulze
If the Configuration first load (i.e. addResource or addDirectory or similar) an entity-mapping and after that a type, which is used by the entity, the call to buildSessionFactory() fails:
> org.hibernate.MappingException: Could not determine type for: testenumtype, at table: TestTable, for columns: [org.hibernate.mapping.Column(ENUM)]
> at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:305)
> at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:289)
> at org.hibernate.mapping.Property.isValid(Property.java:238)
> at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:468)
> at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
> at org.hibernate.cfg.Configuration.validate(Configuration.java:1294)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1736)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782)
> at de.ckc.sschulze.hibernate.testcase.MyTest.testFirstEntityThenType(MyTest.java:37)
In the secondPassCompile the mappings are processed in the order of addition to the Configuration (in case of addDirectory, addJar and addPackage this is quite random). This can cause the HbmBinder not to find the typedef used in an entity, because the typedef is processed after the entity, so the SimpleValue-type is set to the typename in the entity-mapping instead to the name of the type-class.
During validation, the TypeResolver is not able to resolve this typename (because it's no basic type and no classname), so a MappingException is thrown.
I think this issue could be solved by registering a new SecondPass in HbmBinder if no typedef could be found and the type is not a basictype, which resolves this unresolved type.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 4 months
[Hibernate-JIRA] Created: (HHH-5188) Use provided enum type ordinal/string when reading
by Stefan Larsson (JIRA)
Use provided enum type ordinal/string when reading
--------------------------------------------------
Key: HHH-5188
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5188
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.1, 3.5.0-CR-2
Reporter: Stefan Larsson
Priority: Minor
Attachments: EnumType.java-typeSafeNullSafeGet.patch
When Hibernate reads a PostgreSQL enum type using ResultSet.getObject(), the JDBC driver returns a driver-specific PGObject object, which preserves both the value of the enum and its type ordinal/string. Hibernate fails with a ClassCastException when it attempts to cast the PGObject into a String in org.hibernate.type.EnumType.nullSafeGet().
The code in org.hibernate.type.EnumType assumes that ResultSet.getObject() will either return a Number or a String, which is not true for the PostgreSQL driver. IMHO it would be better to let the JDBC driver do the conversion using ResultSet.getInt() or getString() instead.
The attached patch allows JBoss AS 6 M3 (Hibernate 3.5.0-CR-2) to read PostgreSQL enums, using JPA, with a a Java enum annotated as @javax.persistence.Enumerated(javax.persistence.EnumType.STRING).
Also, I believe that perhaps ignoring the given enum type causes Issue HHH-4230, where an ordinal enum was stored in character field. ResultSet.getInteger() might work for that one depending on the JDBC driver.
--
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
12 years, 4 months