[Hibernate-JIRA] Commented: (HHH-1529) session.merge(obj) with an uneffected 1:1 relationship throws an exception
by Juergen Zimmermann (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1529?page=c... ]
Juergen Zimmermann commented on HHH-1529:
-----------------------------------------
Solved by http://opensource.atlassian.com/projects/hibernate/browse/HHH-2138
> session.merge(obj) with an uneffected 1:1 relationship throws an exception
> --------------------------------------------------------------------------
>
> Key: HHH-1529
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1529
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: Windows XP, Hibernate 3.1.2, JDK 5.0_06, PostgreSQL 8.1.2 (Oracle 10g XE beta3 as alternative)
> Reporter: Juergen Zimmermann
> Attachments: use-case-merge.zip
>
>
> Session.merge() crashes with util.JDBCExceptionReporter both on Oracle 10g XE and PostgreSQL 8.1.2. There is no problem when using the Session API and the according update() method. The use case is basically as follows (sources and 3rd party JARs are attached):
> Session session = sf.openSession();
> Transaction trans = session.getTransaction();
> CustomerEntity customer = session.find(CustomerEntity.class, 1L);
> trans.commit();
> session.close();
> customer.setName("Newvalue");
> session = sf.openSession();
> trans = session.getTransaction();
> session.merge(customer); // <== crash
> trans.commit();
> session.close();
> The "customer" object has a 1:1 relationship to an object of class SalesRepEntity. In the log file there is util.JDBCExceptionReporter. The problem is gone if I invoke session.refresh(customer.getSalesRep()) before invoking session.merge(customer). Also the problem is gone if I invoke session.update(customer) instead of session.merge(customer).
> Now the two stack traces (on a German Windows operating system).
> Stacktrace Oracle 10g XE:
>
> org.hibernate.exception.GenericJDBCException: could not load an entity: [de.crm.SalesRepEntity#id=1, name=Alpha]
> at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
> at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
> at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85)
> at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1522)
> at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365)
> at org.hibernate.type.EntityType.resolve(EntityType.java:306)
> at org.hibernate.type.EntityType.replace(EntityType.java:207)
> at org.hibernate.type.TypeFactory.replace(TypeFactory.java:431)
> at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:281)
> at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:247)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:100)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:52)
> at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:701)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:685)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:689)
> at de.crm.Crm.updateCustomer(Crm.java:72)
> at de.crm.Crm.main(Crm.java:32)
> Caused by: java.sql.SQLException: Fehlender IN- oder OUT-Parameter auf Index:: 1
> at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
> at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
> at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)
> at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)
> at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> at org.hibernate.loader.Loader.doQuery(Loader.java:662)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
> ... 16 more
>
> Stacktrace PostgreSQL 8.1.2:
> org.hibernate.exception.DataException: could not load an entity: [de.crm.SalesRepEntity#id=1, name=Alpha]
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:75)
> at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
> at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
> at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85)
> at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1522)
> at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365)
> at org.hibernate.type.EntityType.resolve(EntityType.java:306)
> at org.hibernate.type.EntityType.replace(EntityType.java:207)
> at org.hibernate.type.TypeFactory.replace(TypeFactory.java:431)
> at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:281)
> at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:247)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:100)
> at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:52)
> at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:701)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:685)
> at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:689)
> at de.crm.Crm.updateCustomer(Crm.java:72)
> at de.crm.Crm.main(Crm.java:32)
> Caused by: org.postgresql.util.PSQLException: Für den Parameter 1 wurde kein Wert angegeben.
> at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:134)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:179)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:437)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:257)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> at org.hibernate.loader.Loader.doQuery(Loader.java:662)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
--
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
19 years, 6 months
[Hibernate-JIRA] Closed: (HHH-1568) <subselect> returns stale data, <synchronize> doesn't evict <subselect> objects from session when session is flushed
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1568?page=all ]
Max Rydahl Andersen closed HHH-1568:
------------------------------------
Resolution: Rejected
No, synchronize does not evict data it is used for determining flushing.
Your unit test is basically just verifying that scope of identity is still guaranteed when you are using <subselect>;
if you want the latest data do a session.refresh(staleObject) or do the evict manually.
> <subselect> returns stale data, <synchronize> doesn't evict <subselect> objects from session when session is flushed
> --------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1568
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1568
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: Oracle 10g, Java 5, Windows,
> Reporter: Greg Matthews
> Attachments: SubselectTest.java, subselect_stale_data.log
>
>
> Stale data is being returned from a select against a Hibernate class based on a <subselect> element (instead of a table).
> See detailed log info attached.
> A flush is occuring againt entities referenced within <synchronize> elements in the <subclass> based class, but a subsequent HQL query executed against the <subclass> based class still returns stale data. The log details show that the <subclass> object is retrieved from session.
> Our expectation is that it makes sense for Hibernate to automatically evict objects from session when synchronization causes other entities to be flushed -- otherwise, the whole <synchronization> mechanism is useless and you might as well do everything manually via various evict calls.
> e.g.
> If I have 2 mapping files, one for Table A, and another for a <subselect> based on Table A (let's call this View_A, then I will declare a <synchonized> element in View_A so that any changes to A are flushed before records from View_A are retrieved.
> This seems to work ok in that A is flushed when a query against View_A being executed, but subsequent retrieval of View_A gets loaded from Session, and not from the DB like we'd expect.
> If we manually evict the rows from View_A before executing the HQL query against View_A then up-to-date data is retrieved from View_A.
> Another strange thing is that if we *query* View_A after editing records from A, then the following message appears....
> 12:43:24 DEBUG org.hibernate.engine.ActionQueue.areTablesToUpdated - changes must be flushed to space: A
> ...but if we *load* a record from View_A then this message above does not appear. I would have thought any attempt to access View_A after updates to A had occurred would trigger a flush to A. Hopefully the flush occurs behind the scenes in all cases, and it's just a case of a missing log message in the case of doing a session.load().
--
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
19 years, 6 months
[Hibernate-JIRA] Commented: (HHH-1568) <subselect> returns stale data, <synchronize> doesn't evict <subselect> objects from session when session is flushed
by Greg Matthews (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1568?page=c... ]
Greg Matthews commented on HHH-1568:
------------------------------------
Can someone please look at this issue. Its been sitting here 7 months.
There is even a JUnit test case attached for you to review, SubselectTest.java, which is a modified version of the JUnit test case shipping with Hibernate.
Thanks,
> <subselect> returns stale data, <synchronize> doesn't evict <subselect> objects from session when session is flushed
> --------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-1568
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1568
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: Oracle 10g, Java 5, Windows,
> Reporter: Greg Matthews
> Attachments: SubselectTest.java, subselect_stale_data.log
>
>
> Stale data is being returned from a select against a Hibernate class based on a <subselect> element (instead of a table).
> See detailed log info attached.
> A flush is occuring againt entities referenced within <synchronize> elements in the <subclass> based class, but a subsequent HQL query executed against the <subclass> based class still returns stale data. The log details show that the <subclass> object is retrieved from session.
> Our expectation is that it makes sense for Hibernate to automatically evict objects from session when synchronization causes other entities to be flushed -- otherwise, the whole <synchronization> mechanism is useless and you might as well do everything manually via various evict calls.
> e.g.
> If I have 2 mapping files, one for Table A, and another for a <subselect> based on Table A (let's call this View_A, then I will declare a <synchonized> element in View_A so that any changes to A are flushed before records from View_A are retrieved.
> This seems to work ok in that A is flushed when a query against View_A being executed, but subsequent retrieval of View_A gets loaded from Session, and not from the DB like we'd expect.
> If we manually evict the rows from View_A before executing the HQL query against View_A then up-to-date data is retrieved from View_A.
> Another strange thing is that if we *query* View_A after editing records from A, then the following message appears....
> 12:43:24 DEBUG org.hibernate.engine.ActionQueue.areTablesToUpdated - changes must be flushed to space: A
> ...but if we *load* a record from View_A then this message above does not appear. I would have thought any attempt to access View_A after updates to A had occurred would trigger a flush to A. Hopefully the flush occurs behind the scenes in all cases, and it's just a case of a missing log message in the case of doing a session.load().
--
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
19 years, 6 months
[Hibernate-JIRA] Commented: (HHH-1348) Join w/ Foreign Key within a Single Object not functioing
by Rory Winston (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1348?page=c... ]
Rory Winston commented on HHH-1348:
-----------------------------------
Yeah, thats not going to work. You will need to do it at a higher level than createJoin() (trying to look at this issue myself).
> Join w/ Foreign Key within a Single Object not functioing
> ---------------------------------------------------------
>
> Key: HHH-1348
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1348
> Project: Hibernate3
> Type: Bug
> Environment: Webshpere 5.0
> Reporter: Michael Lambert
>
>
> I have a legacy database I need to join into using something other than the main objects primary key and it simply wont let me join on any field other than the primary key.
> No matter what I insert into "property-ref" it ALWAYS uses the objects primary key in the inner join:
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping package="com.dcx.ps.gpsis.ibsc.data.entities" default-lazy="false">
> <class
> name="HPerson"
> table="PIBPERSN">
> <cache usage="read-write" />
> <id name="id" column="I_PERSN_IBSC" type="long">
> <generator class="increment"/>
> </id>
> <timestamp name="lastUpdated" column="T_STMP_UPD" />
> <property name="lastUpdatedBy" type="string" column="I_USER_UPD" not-null="true" />
> <property name="tid" column="I_USER_LDAP" type="string" not-null="true" unique="true" />
> <property name="description" column="N_USER_LDAP" type="string" not-null="true"/>
> <set name="positions" inverse="true" cascade="save-update">
> <cache usage="read-write" />
> <key column="I_PERSN_IBSC" />
> <one-to-many class="HPosition" />
> </set>
> <join table="PUSRPRF" inverse="true">
> <key column="I_USER_LDAP" property-ref="tid" />
> <property name="firstName" type="string" column="N_FIRST" />
> <property name="lastName" type="string" column="N_LAST" />
> </join>
> </class>
> <query name="findPersonsByName">
> <![CDATA[
> from HPerson person where person.firstName like :firstname and person.lastName like :lastname
> ]]>
> </query>
> <query name="findPersonsByFirstName">
> <![CDATA[
> from HPerson person where person.firstName like :firstname
> ]]>
> </query>
> <query name="findPersonsByLastName">
> <![CDATA[
> from HPerson person where person.lastName like :lastname
> ]]>
> </query>
> <query name="findPersonByTid">
> <![CDATA[
> from HPerson person where person.tid like :tid
> ]]>
> </query>
> <query name="findPersons">
> <![CDATA[
> from HPerson
> ]]>
> </query>
> </hibernate-mapping>
> Results in the following query and error when I execute any query (in this case findPersonByTid has been run):
> could not execute query:
> [select hperson0_.I_PERSN_IBSC as I1_4_, hperson0_.T_STMP_UPD as T2_4_, hperson0_.I_USER_UPD as I3_4_, hperson0_.I_USER_LDAP as I4_4_, hperson0_.N_USER_LDAP as N5_4_, hperson0_1_.N_FIRST as N2_5_, hperson0_1_.N_LAST as N3_5_ from T5279KN.PIBPERSN hperson0_ left outer join T5279KN.PUSRPRF hperson0_1_ on hperson0_.I_PERSN_IBSC=hperson0_1_.I_USER_LDAP where hperson0_.I_USER_LDAP like ?]
> COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/6000] SQL0401N The data types of the operands for the operation "=" are not compatible. SQLSTATE=42818
> Where the outter join SHOULD be hperson0_.I_USER_LDAP =hperson0_1_.I_USER_LDAP; I_PERSN_IBSC is the primary key.
--
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
19 years, 6 months