[Hibernate-JIRA] Commented: (HHH-1460) Inconsistent behavior when using Session.get() with multiple subclasses
by Shawn Windler (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1460?page=c... ]
Shawn Windler commented on HHH-1460:
------------------------------------
I downloaded the source for version 3.2 rc2 in order to test this change.
>From a default download and install, the tests returned the following:
840 Tests ran 9 Failures 4 Errors 98.45% Success rate 46.792 Seconds
After the change:
840 Tests ran 16 Failures 29 Errors 94.64% Success Rate 57.565 Seconds
Obviously, this change had a greater impact than I previously had hoped it would. I'm not sure how to fix all these problems, but hopefully someone with a little more experience with the code and the design can lend some insight.
I'm kind of confused as to how the inheritance would work otherwise.
One mapping file. Two subclasses in the mapping file, sharing one id. There doesn't seem to be a good way to make sure a session.get( Class class, Serializable id ) call returns the correct subclass.
> Inconsistent behavior when using Session.get() with multiple subclasses
> -----------------------------------------------------------------------
>
> Key: HHH-1460
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1460
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: Hibernate 3.1.2
> HSQLDB 1.8.0.2
> Java 1.5.0_05-b05
> Reporter: Seth Fitzsimmons
> Attachments: ClassCastException.zip
>
>
> Session.get() loads a cached instance of an alternate subclass with the same PK after that subclass has been loaded directly (throwing a ClassCastException where null was expected). When attempting to load it without prior loading, null is returned, as expected.
> Client and Partner both extend person and have discriminator values of 1 and 2, respectively. There is a single entry in the database (a Client) with a PK of 0.
> This should be null:
> Partner partner = (Partner) getSession().get(Partner.class, 0);
> assertNull(partner);
> It is. However, if the Client is loaded first, Hibernate will attempt to return a Partner (as a Client) where it should not exist:
> Client client = (Client) getSession().get(Client.class, 0);
> assertNotNull(client);
>
> // this should be null, not return a Client object (resulting in a ClassCastException)
> Partner partner = (Partner) getSession().get(Partner.class, 0);
> assertNull(partner);
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1740) Build-time instrumentation breaks lazy="proxy"
by Frank Grimes (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1740?page=c... ]
Frank Grimes commented on HHH-1740:
-----------------------------------
Well, in case you missed it, I did attach HHH-1740.diff to this JIRA on June 2nd to demonstrate the failure.
If that test case was somehow lacking, I would expect to be told so. (I'm not a mind-reader after all)
> Build-time instrumentation breaks lazy="proxy"
> ----------------------------------------------
>
> Key: HHH-1740
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1740
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2
> Reporter: Frank Grimes
> Assignee: Steve Ebersole
> Priority: Critical
> Fix For: 3.2.0.ga
> Attachments: 312Document.class, Document.class, HHH-1740.diff
>
>
> I have a mapping that contains a many-to-one lazy="proxy".
> This alone works fine: I see $$EnhancerByCGLIB$$ as the type when I do a load
> Once I add a lazy property to the mapping and do build-time cglib enhancement, it breaks.
> Not only is the lazy property listed in $CGLIB_READ_WRITE_CALLBACK, but also my lazy="proxy" association. (i.e. no more proxy object)
> This works fine in hibernate-3.1.2.
> This was originally brought up here: http://forums.hibernate.org/viewtopic.php?t=958881
> Please let me know if more info or a test case is needed.
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1740) Build-time instrumentation breaks lazy="proxy"
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1740?page=c... ]
Steve Ebersole commented on HHH-1740:
-------------------------------------
Well, AFAIK I we are *still* waiting on somebody to provide us with a failing test case illustrating this failure. In the absence of that, I went ahead and implemented one on my own (org.hibernate.test.instrument.cases.TestManyToOneProxyExecutable) to validate this. It did in fact initially fail. I then implemented a fix and it then did indeed pass. I mean what more is it you want me to do? Beg for a test case? Say 'pretty please'? 'with sugar on top'?
> Build-time instrumentation breaks lazy="proxy"
> ----------------------------------------------
>
> Key: HHH-1740
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1740
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2
> Reporter: Frank Grimes
> Assignee: Steve Ebersole
> Priority: Critical
> Fix For: 3.2.0.ga
> Attachments: 312Document.class, Document.class, HHH-1740.diff
>
>
> I have a mapping that contains a many-to-one lazy="proxy".
> This alone works fine: I see $$EnhancerByCGLIB$$ as the type when I do a load
> Once I add a lazy property to the mapping and do build-time cglib enhancement, it breaks.
> Not only is the lazy property listed in $CGLIB_READ_WRITE_CALLBACK, but also my lazy="proxy" association. (i.e. no more proxy object)
> This works fine in hibernate-3.1.2.
> This was originally brought up here: http://forums.hibernate.org/viewtopic.php?t=958881
> Please let me know if more info or a test case is needed.
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1740) Build-time instrumentation breaks lazy="proxy"
by Frank Grimes (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1740?page=c... ]
Frank Grimes commented on HHH-1740:
-----------------------------------
Hi Steve,
I've checked out the latest from the 3.2 branch and my test case still fails.
Also, I intermittently get the following errors from the instrument tests:
Cannot open connection
org.hibernate.exception.JDBCConnectionException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326) at org.hibernate.test.instrument.cases.TestDirtyCheckExecutable.execute(TestDirtyCheckExecutable.java:19) at org.hibernate.test.instrument.buildtime.InstrumentTest.execute(InstrumentTest.java:59) at org.hibernate.test.instrument.buildtime.InstrumentTest.testDirtyCheck(InstrumentTest.java:29) at org.hibernate.test.TestCase.runTest(TestCase.java:162) at org.hibernate.test.instrument.buildtime.InstrumentTest.runTest(InstrumentTest.java:72) at org.hibernate.test.TestCase.runBare(TestCase.java:402)Caused by: java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@dec476cb[file =D:\eclipse-3.1\workspaces\invex-stratix\Hibernate3-Branch_3_2\Hibernate3\build\db\hsqldb\hibernate.lck, exists=true, locked=false, valid=false, fl =null]: java.lang.Exception: checkHeartbeat(): lock file [D:\eclipse-3.1\workspaces\invex-stratix\Hibernate3-Branch_3_2\Hibernate3\build\db\hsqldb\hibernate.lck] is presumably locked by another process. at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source) at org.hsqldb.jdbcDriver.getConnection(Unknown Source) at org.hsqldb.jdbcDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:140) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417) ... 25 more
> Build-time instrumentation breaks lazy="proxy"
> ----------------------------------------------
>
> Key: HHH-1740
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1740
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.3, 3.2.0 cr1, 3.2.0.cr2
> Reporter: Frank Grimes
> Assignee: Steve Ebersole
> Priority: Critical
> Fix For: 3.2.0.ga
> Attachments: 312Document.class, Document.class, HHH-1740.diff
>
>
> I have a mapping that contains a many-to-one lazy="proxy".
> This alone works fine: I see $$EnhancerByCGLIB$$ as the type when I do a load
> Once I add a lazy property to the mapping and do build-time cglib enhancement, it breaks.
> Not only is the lazy property listed in $CGLIB_READ_WRITE_CALLBACK, but also my lazy="proxy" association. (i.e. no more proxy object)
> This works fine in hibernate-3.1.2.
> This was originally brought up here: http://forums.hibernate.org/viewtopic.php?t=958881
> Please let me know if more info or a test case is needed.
--
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, 5 months
[Hibernate-JIRA] Commented: (HHH-1460) Inconsistent behavior when using Session.get() with multiple subclasses
by Shawn Windler (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1460?page=c... ]
Shawn Windler commented on HHH-1460:
------------------------------------
In my opinion, this should return null. If I am using a discriminator to decide between subclasses, then the cache should respect the discriminator as well.
After looking through the source, I have located where a problem *may* lie. When caching objects, an EntityKey is used as the key for the HashMap. The hashcode for this is based on the rootEntityName, rather than the entityName, so all subclasses are cached as the superclass. Any other subclass of that superclass can return any 'sibling' class as long as it provides a correct and already-cached id.
Correct me if I'm wrong. I know that you guys have a lot more experience with this code than I do and I'd rather not break the caching.
If you could provide an explanation why rootEntityName was being used instead of entityName, that'd help me out. Without going through all the code to understand it, I can't be sure that these changes will affect anything else.
---------------------------
Changes:
org.hibernate.engine.EntityKey.java:102 (the generateHashCode() method)
OLD: result = 37 * result + rootEntityName.hashCode();
NEW: result = 37 * result + entityName.hashCode();
* Also, the equals( Object other ) would likely need to be changed to use entityName as well, in order to uphold the contract of hashcode(): http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#hashCode()
---------------------------
Note: This was the most recent issue involving this problem, so I added this comment here. If there is a better place for it, please let me know and I will get it moved.
Let me know if you have any questions or if I can provide any more information.
> Inconsistent behavior when using Session.get() with multiple subclasses
> -----------------------------------------------------------------------
>
> Key: HHH-1460
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1460
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: Hibernate 3.1.2
> HSQLDB 1.8.0.2
> Java 1.5.0_05-b05
> Reporter: Seth Fitzsimmons
> Attachments: ClassCastException.zip
>
>
> Session.get() loads a cached instance of an alternate subclass with the same PK after that subclass has been loaded directly (throwing a ClassCastException where null was expected). When attempting to load it without prior loading, null is returned, as expected.
> Client and Partner both extend person and have discriminator values of 1 and 2, respectively. There is a single entry in the database (a Client) with a PK of 0.
> This should be null:
> Partner partner = (Partner) getSession().get(Partner.class, 0);
> assertNull(partner);
> It is. However, if the Client is loaded first, Hibernate will attempt to return a Partner (as a Client) where it should not exist:
> Client client = (Client) getSession().get(Client.class, 0);
> assertNotNull(client);
>
> // this should be null, not return a Client object (resulting in a ClassCastException)
> Partner partner = (Partner) getSession().get(Partner.class, 0);
> assertNull(partner);
--
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, 5 months