[Hibernate-JIRA] Created: (HHH-3348) loading context
by benjamin Leroux (JIRA)
loading context
---------------
Key: HHH-3348
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3348
Project: Hibernate3
Issue Type: New Feature
Affects Versions: 4.x
Reporter: benjamin Leroux
Priority: Minor
this proposal is for creating a loading context into hibernate
Let me explain:
On an application, we often hesitating between the two major strategies of loading (eager or lazy). But for some reason there has no good choice. In fact, it depends on the context.
So we do lazy loading and redefine some method with new request with some "join". In fact, it lead to complexity and decrease managability of the application.
So my idea is to allow the definition of a context (like transactional context) where we we can put the loading strategie to adopt.
with annotation it could be very easy to define such context. Let see this exemple :
Avec les annotations, cela pourrait conduire à une ecriture de ce style :
@LoadingStrategie (type=eager from="Car" get={"driver"})
public List<Car> getAllCarForDriving(){
// Some fonctions
}
@LoadingStrategie (type=eager from="Car" get={"driver","passengers"})
public List<Car> getAllCarForTravelling(){
// Some fonctions
}
In the method getAllCarForDriving when we call a hql request on car it automaticaly get driver but in the method getAllCarForTravelling passengers and the driver is loaded.
--
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
13 years
[Hibernate-JIRA] Created: (HHH-6604) confusing error message when OneToOne has a duplicate on one end
by Laura Dean (JIRA)
confusing error message when OneToOne has a duplicate on one end
----------------------------------------------------------------
Key: HHH-6604
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6604
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6, 4.x
Environment: originally found with hibernate 3.6.6 and MS SQL Server; also happens when run in a hibernate unit test.
Reporter: Laura Dean
Priority: Minor
Attachments: OneToOne-error-message.patch
Suppose I have a Trousers entity with id 1, that knows about its TrousersZip, which has id 2. That is, my Trousers has zip_id = 2. (This part of the example comes from Hibernate's unit tests.)
Suppose the Trousers has a TrousersHanger, also one-to-one, but mapped on the TrousersHanger side. That is, the hanger points to its Trousers.
Now suppose I put two TrousersHangers into the database, both pointing at the same Trousers. (Naughty, I know; in the real world, it happened because of HHH-6484.)
When I then try to load the Trousers from the database, I get a very confusing error message:
org.hibernate.HibernateException: More than one row with the given identifier was found: 2, for class: org.hibernate.test.annotations.onetoone.Trousers
The message confuses me for three reasons:
1. I have only one row in the Trousers table.
2. That one row has ID 1.
3. My actual problem is with duplicate TrousersHangers, and neither one of them has ID 2.
In other words, where the heck did ID 2 come from?
As it turns out, hibernate finds the Trousers by id, then finds the Trousers by zip_id (to populate the TrousersZip object). It doesn't care about the duplicate results in the first query, but it does care the second time. But the error message doesn't mention that its ID is actually the zip_id, and a person could waste quite a bit of time before figuring out that the TrousersZip had anything to do with it. (Well, maybe not in this contrived example with only 3 entities. But in the real world, yeah.)
I've attached a junit test, adding to hibernate's own OneToOneTest.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years
[Hibernate-JIRA] Created: (HHH-5184) Create a ConnectionAcquisitionMode as corollary to ConnectionReleaseMode
by Steve Ebersole (JIRA)
Create a ConnectionAcquisitionMode as corollary to ConnectionReleaseMode
------------------------------------------------------------------------
Key: HHH-5184
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5184
Project: Hibernate Core
Issue Type: Improvement
Reporter: Steve Ebersole
Fix For: 3.6
Originally ConnectionReleaseMode was added to work around a particular problem of connection "leaking" by JTA containers when used in situations of nested session EJB calls. The connection was not really leaked, but it would appear that way to the JTA resource tracker.
The situation was:
{code}
class EJB1 {
public void doSomething() {
Session s = getCurrentSession();
...
ejb2.doSomethingElse();
// now use the HIbernate session
}
}
class EJB2 {
public void doSomethingElse() {
Session s = getCurrentSession();
// Use the session in a way that requires a Connection...
}
}
{code}
What happens is that EJB1 obtains a Session reference. Just getting a Hibernate Session does not make it get a Connection; the Session delays getting a Connection until it actually needs one. EJB1 then makes the call into EJB2. Again, EJB2 obtains the same Session reference and does some work, so the Session obtains a Connection. Historically that Connection would be held until the Session closed. However that was problematic in this scenario above; to the JTA container it looks like EJB2.doSomethingElse() is leaking the connection outside the transaction boundary (this was many years ago and AFAIU many of these JTA scoping routines have become more sophisticated).
At the time we decided to add the idea of Connection "releasing". However constantly releasing and re-obtaining the Connection can affect performance. Another solution to the problem above is to obtain the Connection up front instead.
So initially I see:
ConnectionAcquisitionMode.AS_NEEDED
ConnectionAcquisitionMode.IMMEDIATELY
--
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
13 years