[Hibernate-JIRA] Created: (HHH-2588) Incorrect database updates with "generated" fields in record
by Frits Jalvingh (JIRA)
Incorrect database updates with "generated" fields in record
------------------------------------------------------------
Key: HHH-2588
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2588
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3, 3.2.0.ga
Environment: Tested with Hibernate 3.2.3 and 3.2.0GA, Oracle 10gR2, Linux, Java 5.
Reporter: Frits Jalvingh
I have a single POJO (UserGroup) which is based on a superclass which defines a number of properties as @Generated(GenerationTime.INSERT); amongst others tcn and ros_id. These properties are defined as "not null" in the database, and are filled in by an insert database trigger.
When I create a new instance and do this:
--------------------
Transaction tr = getSession().beginTransaction();
UserGroup ug = new UserGroup();
ug.setType(UserGroupType.PLN);
ug.setName(name);
ug.setDescription(desc);
getSession().save(ug); // persist() exhibits the same problem...
ug.setGroupEmail("jaja(a)nono.com");
tr.commit();
--------------------
I get a database exception: ORA-01407: cannot update ("TEST"."CRM_GROUPS"."ROS_ID") to NULL
When I look at the persister's logging I see something very wrong happening:
--------------------
DEBUG - commit
DEBUG - automatically flushing session
DEBUG - flushing session
DEBUG - processing flush-time cascades
DEBUG - dirty checking collections
DEBUG - Flushing entities and processing referenced collections
DEBUG - nl.itris.viewpoint.db.crm.UserGroup.groupEmail is dirty
DEBUG - nl.itris.viewpoint.db.crm.UserGroup.memberMutable is dirty
DEBUG - Updating entity: [nl.itris.viewpoint.db.crm.UserGroup#1150000159]
DEBUG - nl.itris.viewpoint.db.crm.UserGroup.groupEmail is dirty
DEBUG - nl.itris.viewpoint.db.crm.UserGroup.memberMutable is dirty
DEBUG - Collection found: [nl.itris.viewpoint.db.crm.UserGroup.memberList#1150000159], was: [<unreferenced>] (initialized)
DEBUG - Processing unreferenced collections
DEBUG - Scheduling collection removes/(re)creates/updates
DEBUG - Flushed: 1 insertions, 1 updates, 0 deletions to 1 objects
DEBUG - Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
DEBUG - listing entities:
DEBUG - nl.itris.viewpoint.db.crm.UserGroup{groupEmail=jal(a)etc.to, memberList=[], type=PLN, tcn=null, logTime=null, logModule=null, id=1150000159, organisationId=null, groupLeader=null, description=test2, memberMutable=null, logDate=null, name=test2, logUser=null}
DEBUG - executing flush
DEBUG - registering flush begin
DEBUG - Inserting entity: [nl.itris.viewpoint.db.crm.UserGroup#1150000159]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - insert into CRM_GROUPS (CGP_DESCRIPTION, CGP_GROUPEMAIL, CST_ID, CGP_MEMBER_MUTABLE, CGP_NAME, CGP_TYPE, CGP_ID) values (?, ?, ?, ?, ?, ?, ?)
DEBUG - preparing statement
DEBUG - Dehydrating entity: [nl.itris.viewpoint.db.crm.UserGroup#1150000159]
DEBUG - binding 'test2' to parameter: 1
DEBUG - binding null to parameter: 2
DEBUG - binding null to parameter: 3
DEBUG - binding 'test2' to parameter: 5
DEBUG - Binding 'PLN' to parameter: 6
DEBUG - binding '1150000159' to parameter: 7
DEBUG - Executing batch size: 1
DEBUG - success of batch update unknown: 0
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - closing statement
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select usergroup_.LOG_DATE as LOG2_74_, usergroup_.LOG_MODULE as LOG3_74_, usergroup_.LOG_TIME as LOG4_74_, usergroup_.LOG_USER as LOG5_74_, usergroup_.TCN as TCN74_, usergroup_.ROS_ID as ROS7_74_ from CRM_GROUPS usergroup_ where usergroup_.CGP_ID=?
DEBUG - preparing statement
DEBUG - binding '1150000159' to parameter: 1
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - returning '2007-04-26 00:00:00' as column: LOG2_74_
DEBUG - returning null as column: LOG3_74_
DEBUG - returning '14:28:04' as column: LOG4_74_
DEBUG - returning 'VPC' as column: LOG5_74_
DEBUG - returning '310525020' as column: TCN74_
DEBUG - returning '1500' as column: ROS7_74_
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - Updating entity: [nl.itris.viewpoint.db.crm.UserGroup#1150000159]
DEBUG - about to open PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - update CRM_GROUPS set TCN=?, ROS_ID=?, CGP_DESCRIPTION=?, CGP_GROUPEMAIL=?, CST_ID=?, CGP_MEMBER_MUTABLE=?, CGP_NAME=?, CGP_TYPE=? where CGP_ID=?
DEBUG - preparing statement
DEBUG - Dehydrating entity: [nl.itris.viewpoint.db.crm.UserGroup#1150000159]
DEBUG - binding null to parameter: 1
DEBUG - binding null to parameter: 2
DEBUG - binding 'test2' to parameter: 3
DEBUG - binding 'jal(a)etc.to' to parameter: 4
DEBUG - binding null to parameter: 5
DEBUG - binding 'test2' to parameter: 7
DEBUG - Binding 'PLN' to parameter: 8
DEBUG - binding '1150000159' to parameter: 9
DEBUG - Executing batch size: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 2, globally: 2)
DEBUG - closing statement
DEBUG - Could not execute JDBC batch update [update CRM_GROUPS set TCN=?, ROS_ID=?, CGP_DESCRIPTION=?, CGP_GROUPEMAIL=?, CST_ID=?, CGP_MEMBER_MUTABLE=?, CGP_NAME=?, CGP_TYPE=? where CGP_ID=?]
to.etc.dbpool.BetterSQLException: java.sql.BatchUpdateException: ORA-01407: cannot update ("VIEWPOINT"."CRM_GROUPS"."ROS_ID") to NULL
SQL: update CRM_GROUPS set TCN=?, ROS_ID=?, CGP_DESCRIPTION=?, CGP_GROUPEMAIL=?, CST_ID=?, CGP_MEMBER_MUTABLE=?, CGP_NAME=?, CGP_TYPE=? where CGP_ID=?
Parameters:
#1:[null]
#2:[null]
#3:java.lang.String:test2
#4:java.lang.String:jal@etc.to
#5:[null]
#6:java.lang.String:N
#7:java.lang.String:test2
#8:java.lang.String:PLN
#9:java.lang.Long:1150000159
at to.etc.dbpool.PreparedStatementProxy.wrap(PreparedStatementProxy.java:68)
at to.etc.dbpool.StatementProxy.executeBatch(StatementProxy.java:176)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
at org.hibernate.persister.entity.AbstractEntityPersister.processGeneratedProperties(AbstractEntityPersister.java:3691)
at org.hibernate.persister.entity.AbstractEntityPersister.processUpdateGeneratedProperties(AbstractEntityPersister.java:3680)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:124)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at nl.itris.moca.ajax.Planner.updatePlanGroup(Planner.java:1717)
----------------------------------
Hibernate starts by inserting the new record correctly, and then reselects the inserted record to retrieve the changed fields correctly. But after that it does an update of that record with stale data: it sets all of the generated fields it *has* read to null, and updates the groupEmail field which for some reason was not present in the insert!?
It looks like multiple versions of the same records are maintained in some way??
The problem is triggered by the existence of the "save" call *followed by* another change to the record. But the same problem occurs when other things cause an intermediary update, for instance when trying to save the data in a collection parented by UserGroup.
Because this problem also occurs when I add/change elements in the UserGroup's associated GroupMember one-to-many association I am effectively unable to store a group with it's members in one transaction!
In addition I noticed that the persist() call seems to check defined constraints on the record at the time persist() is called instead of the time that it gets commited. This means it can only be called when the pojo is complete which looks odd to me? I sort of understand this for save() as that is required to return the primary key but I do not understand why this is needed for persist...
--
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
16 years, 11 months
[Hibernate-JIRA] Created: (HV-26) Which version of Hibernate Annotations does ClassValidator depend on?
by Steven Devijver (JIRA)
Which version of Hibernate Annotations does ClassValidator depend on?
---------------------------------------------------------------------
Key: HV-26
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-26
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 3.0.0.ga
Reporter: Steven Devijver
According to the Compatibility Matrix on the Hibernate website (http://www.hibernate.org/6.html) Hiberbate Validator 3.3.0 GA depends on Hibernate Annotations 3.3.x.
The only 3.3.x release of Hibernate Annotations is 3.3.0 GA. However, the dependency in the compatibility matrix does not seem to be correct.
When I load ClassValidator in my project I get this error:
The type org.hibernate.annotations.common.reflection.ReflectionManager cannot be resolved. It
is indirectly referenced from required .class files
Version 3.3.0 GA of Hibernate Annotations however does not have the class org.hibernate.annotations.common.reflection.ReflectionManager. It does however contain org.hibernate.annotations.common.reflection.EJB3ReflectionManager.
So, which version of Hibernate Annotations should be used with Hibernate Validator 3.0.0 GA?
--
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
16 years, 11 months
[Hibernate-JIRA] Created: (EJB-285) EJB3 compliant default settings override hibernate.cfg.xml
by Rodolfo Federico Gamarra (JIRA)
EJB3 compliant default settings override hibernate.cfg.xml
----------------------------------------------------------
Key: EJB-285
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-285
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.1.GA
Environment: Hibernate 3.2.1
Hibernate EntityManager 3.3.1.GA
Reporter: Rodolfo Federico Gamarra
Priority: Minor
Attachments: entitymanager-configuration.zip
Hi, I think I've found a little bug in org.hibernate.ejb.Ejb3Configuration ($Id: Ejb3Configuration.java 11344 2007-03-25 18:24:01Z epbernard $) class.
Hopefully the title is clear enough to describe what's happening:
- I've a persitence.xml which references (via "hibernate.ejb.cfgfile") a hibernate.cfg.xml, in the way that's described, for example, in the Entity Manager User Guide (Version: 3.3.1.GA. Page 8, below "Here is a typical configuration in a J2SE environment").
- In the referenced xml I set the auto commmit property in false and in persistence.xml nothing it's said about that property.
- What I see at the end of the startup is that the value is true.
Posible explanation:
- Take a look at Ejb3Configuration, specially the methods:
- configure(Properties properties, Map workingVars)
- prepareProperties(Properties properties, Map workingVars)
- A pseudo-code for the first may be:
1) Prepare properties (load persistence.xml):
//settings that always apply to a compliant EJB3
preparedProperties.setProperty( Environment.AUTOCOMMIT, "true" );
2) Load the referenced "hibernate.ejb.cfgfile".
I saw in debugging that the actual false value gets loaded.
3) Priorize persistence.xml over hibernate.cfg.xml:
cfg.addProperties( preparedProperties ); //persistence.xml has priority over hibernate.Cfg.xml
The problem with the last line (besides the typo in the comment, in the extension :-)) is that, I think, that priorization doesn't consider that maybe the values in the prepared properties are there because a default (and not because they were acctually configured in the xml).
After reading "READ THIS BEFORE USING JIRA!", I took a look in the already reported things but didn't get to the problem (In fact, I was using an older verion and, so, I made an update and tried with the lattest one). Also, as you say "Don't attach your project folder as a Zip file, but only the relevant files. Please don't upload them one-by-one, but packaged in a Zip": I made a dummy project (Eclipse 3.2) which shows the problem. I setup log4j properties into debug mode, where the beforementioned can be saw. Also I added some reflection code in order to see the configuration values after the startup process has finished. I also used some other properties in order to have some combinations: a property defined in both xmls (persistence wins), just in persistence, just in hibernate and gets overrided (autocommit), just in hibernate but doesn't get overrided (user name). I hope that I didn't misundertood "...don't attach your project...", what I attached is a tiny-example-oriented project; from which the relevant files are "persistence.xml" and "hibernate.cfg.xml".
In the heading of the log (which is in root of the project in console.txt) you can see the versions of Hibernate, in particular Hibernate EntityManager 3.3.1.GA.
--
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
16 years, 11 months
[Hibernate-JIRA] Created: (HHH-2677) Not loading the ORM.xml file
by Adi (JIRA)
Not loading the ORM.xml file
----------------------------
Key: HHH-2677
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2677
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.0.ga
Environment: Windows XP,MySQL5.0,Hibernate3.2.0
Reporter: Adi
Priority: Minor
Attachments: persistence.zip
IF the name of the orm.xml is anything different, then Hibernate is not loading the orm file.
Following is the error I am getting:
java.lang.ExceptionInInitializerError
at com.iChieve.domain.entity.ProductCategoryUnitTest.testSave(ProductCategoryUnitTest.java:16)
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 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 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)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: simpleJPA-PersistenceUnit] Unable to find XML mapping file in classpath: /META-INF/myorm.xml
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:914)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:772)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:183)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:240)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at com.iChieve.dao.EntityManagerHelper.<clinit>(EntityManagerHelper.java:20)
... 17 more
--
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
16 years, 11 months