[Hibernate-JIRA] Created: (HHH-5410) Ability to get the equivalent sql from HQL or Criteria query with final parameter values of complex Hibernate Custom Type
by radhakrishna (JIRA)
Ability to get the equivalent sql from HQL or Criteria query with final parameter values of complex Hibernate Custom Type
-------------------------------------------------------------------------------------------------------------------------
Key: HHH-5410
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5410
Project: Hibernate Core
Issue Type: New Feature
Reporter: radhakrishna
Ability to get sql from HQL/Criteria queries and final sql parameter values injected into positional parameters, instead of a prepared statement.
Hibernate Tools displays sql as when we type the HQL (fails for criteria queries), but there is no way to access them NOT AS prepared statements to debug it.
HQL: "from Entity where prop1 = '1' and prop2 = 2"
CRITERIA: session.createCriteria(Entity.class)
.add(Restrictions.eq("prop1",'1'))
.add(Restrictions.eq("prop2",2))
These two are not the same, because the criteria query executes it as a prepared statement or is there a way to inject constant parameters like the above HQL using criteria queries? How do we force the HQL or criteria to not execute it as a prepared statement or return the equivalent SQL?
The sql is usesful in customizing such as in case of "union" queries.
--
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
14 years, 5 months
[Hibernate-JIRA] Created: (HHH-3771) Best pactice for equals implementation?
by Samppa Saarela (JIRA)
Best pactice for equals implementation?
---------------------------------------
Key: HHH-3771
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3771
Project: Hibernate Core
Issue Type: New Feature
Components: core, documentation
Reporter: Samppa Saarela
When domain model contains even one lazy reference to an object, default equals fails when it's compared to a) the actual implementation returned by Session.get/load or b) other proxies (at least of different supertype). Overriding equals on a class that uses surrogate id is not that simple. However there is a simple solution to this problem:
In domain class, override equals like this:
public boolean equals(Object obj) {
return this == getImplementation(obj);
}
public static Object getImplementation(Object obj) {
if (obj instanceof HibernateProxy) {
return ((HibernateProxy) obj).getHibernateLazyInitializer().getImplementation();
} else {
return obj;
}
}
This should result always in comparing object references of actual instances and thus preserve symmetry.
It's understandable that you don't wan to publish that kind of getImplementation utility e.g. in Hibernate, but maybe you could support this more directly by implementing
Hibernate.equals(Object o1, Object o2)
--
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
14 years, 5 months