[Hibernate-JIRA] Updated: (HHH-1685) DetachedCriteria doesn't create alias on subcriteria
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685?page=c... ]
Diego Pires Plentz updated HHH-1685:
------------------------------------
Assignee: Diego Pires Plentz
Affects Version/s: (was: 3.1.3)
3.2.5
> DetachedCriteria doesn't create alias on subcriteria
> ----------------------------------------------------
>
> Key: HHH-1685
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.2.5
> Reporter: John
> Assignee: Diego Pires Plentz
> Attachments: hhh1685-example.txt
>
>
> DetachedCriteria has two createCriteria methods:
> public DetachedCriteria createCriteria(String associationPath) throws HibernateException
> public DetachedCriteria createCriteria(String associationPath, String alias) throws HibernateException
> However, the code for both was identical - they called the inner criteria's createCriteria(String) method. The version with the alias did not call the inner's version with the alias. The following patch snipped shows the change:
> public DetachedCriteria createCriteria(String associationPath, String alias)
> throws HibernateException {
> - return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
> + return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
> }
> This bug was discovered while trying to link a 2-deep subquery to its parent via aliases. (Surfacing this issue might only be possible with the patch HHH-952 in place - I'm not sure. Seems like a bug regardless, as it definitely fixed my alias reference issue.) I'll get an example posted shortly.
--
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, 8 months
[Hibernate-JIRA] Updated: (HHH-925) DetachedCriteria.createCriteria not working with alias
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-925?page=co... ]
Diego Pires Plentz updated HHH-925:
-----------------------------------
Priority: Major (was: Minor)
Assignee: Diego Pires Plentz
Environment: Oracle (was: Hibernate 3.0.5, Oracle)
Affects Version/s: (was: 3.1 beta 2)
(was: 3.1 beta 1)
(was: 3.0.5)
(was: 3.0.4)
(was: 3.0.3)
(was: 3.0.2)
(was: 3.0.1)
(was: 3.0 final)
(was: 3.0 rc 1)
(was: 3.0 beta 4)
(was: 3.0 beta 3)
(was: 3.0 beta 2)
(was: 3.0 beta 1)
(was: 3.0 alpha)
3.2.5
Fix Version/s: 3.2.6
Component/s: (was: core)
query-criteria
> DetachedCriteria.createCriteria not working with alias
> ------------------------------------------------------
>
> Key: HHH-925
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-925
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.2.5
> Environment: Oracle
> Reporter: Felipe Cuozzo
> Assignee: Diego Pires Plentz
> Fix For: 3.2.6
>
> Attachments: DetachedCriteria.patch
>
> Original Estimate: 10 minutes
> Remaining Estimate: 10 minutes
>
> DetachedCriteria.createCriteria(associationPath, alias) is calling the wrong Criteria.createCriteria method
> public DetachedCriteria createCriteria(String associationPath, String alias)
> throws HibernateException {
> return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
> }
> should be:
> public DetachedCriteria createCriteria(String associationPath, String alias)
> throws HibernateException {
> return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
> }
--
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, 8 months
[Hibernate-JIRA] Updated: (HHH-1832) Expression.in on component object gives parameters til SQL in wrong order.
by Pertti Erkkilä (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1832?page=c... ]
Pertti Erkkilä updated HHH-1832:
--------------------------------
Attachment: HibernateBugTestCase.java
Test case proving the problem. Using mocks to simulate component type without multiple files.
> Expression.in on component object gives parameters til SQL in wrong order.
> --------------------------------------------------------------------------
>
> Key: HHH-1832
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1832
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.1.2
> Environment: Development in IntellIJ IDEA 4.5.3
> Database:Oracle 10g Enteprise Edition release 10.1.0.2.0
> Reporter: Thomas Andersen
> Attachments: HibernateBug.zip, HibernateBugTestCase.java
>
>
> I'm using an Expression.in on a component class with two attributes (one Long and one String). When executing the code I an empty list.
> When using the generated SQL in DBVisualizer adding the variables it returns the expectet list.
> Debug log level and reveals (detailed documentation later in description):
> Parameters are bound in the wrong order:
> Paramters are bound
> ... where (this_.ejerlavskode, this_.matrikelnr) in ((9999, 9999), (01, 03))
> should be 9999, 01, 9999, 03 according to
> ... where (this_.ejerlavskode, this_.matrikelnr) in ((9999, 01), (9999, 03))
> Parameter pairs are by class Matrikelbetegnelse(ejerlavskode=9999, matrikenr=01)
> Hibernate version:
> Hibernate 3.1.2
> Mapping documents:
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping
> <class
> name="Sagsadvarsel"
> table="sagsadvarsel"
> >
> <id
> name="id"
> column="id"
> type="long"
> >
> <generator class="native">
> <param name="sequence">sagsadvarsel_id_seq</param>
> </generator>
> </id>
> <version
> name="version"
> column="version"
> type="long"
> />
> <property
> name="datoTid"
> type="java.util.Date"
> update="true"
> insert="true"
> column="datoTid"
> not-null="false"
> />
> <component
> name="matrikelbetegnelse"
> class="Matrikelbetegnelse"
> >
> <property
> name="ejerlavskode"
> type="java.lang.Long"
> update="true"
> insert="true"
> column="ejerlavskode"
> />
> <property
> name="matrikelnr"
> type="java.lang.String"
> update="true"
> insert="true"
> column="matrikelnr"
> length="20"
> />
> </component>
> </class>
> </hibernate-mapping>
> Code between sessionFactory.openSession() and session.close():
> Long ejerlav = new Long(9999);
> final Matrikelbetegnelse[] matrikelbetegnelser = new Matrikelbetegnelse[2];
> matrikelbetegnelser[0] = new Matrikelbetegnelse(ejerlav, "01");
> matrikelbetegnelser[1] = new Matrikelbetegnelse(ejerlav, "03");
> List list = session.createCriteria(Sagsadvarsel.class)
> .add(Expression.in("matrikelbetegnelse",matrikelbetegnelser))
> .list();
> log.debug("list " + list.size());
> import java.util.Date;
> import java.io.Serializable;
> /**
> * @hibernate.class table="sagsadvarsel"
> */
> public class Sagsadvarsel implements Serializable{
> private long id;
> private long version;
> private Date datoTid;
> private Matrikelbetegnelse matrikelbetegnelse;
> /**
> * @return
> * @hibernate.id generator-class="native"
> */
> public long getId() {
> return id;
> }
> public void setId(long id) {
> this.id = id;
> }
> /**
> * Udlever versionsnummer for forekomsten. Feltet ajourføres af Hibernate, som samtidig bruger det til at
> * forhindre samtidig opdatering fra to processer.
> * hibernate.version
> * @return
> */
> public long getVersion() {
> return version;
> }
> public void setVersion(long version) {
> this.version = version;
> }
> /**
> * Udlever datotid (Dato og tidspunkt for sagsadvarsel).
> *
> * @hibernate.property not-null="false"
> * @return datotid
> */
> public Date getDatoTid() {
> return datoTid;
> }
> public void setDatoTid(Date datoTid) {
> this.datoTid = datoTid;
> }
> /**
> * Udlever Matrikelbetegnelse.
> *
> * @hibernate.component
> */
> public Matrikelbetegnelse getMatrikelbetegnelse() {
> return matrikelbetegnelse;
> }
> public void setMatrikelbetegnelse(Matrikelbetegnelse matrikelbetegnelse) {
> this.matrikelbetegnelse = matrikelbetegnelse;
> }
> }
> import java.io.Serializable;
> /**
> */
> public class Matrikelbetegnelse {
> private Long ejerlavskode ;
> private String matrikelnr ;
> public Matrikelbetegnelse() {
> }
> public Matrikelbetegnelse(Long ejerlavskode, String matrikelnummer) {
> this.ejerlavskode = ejerlavskode;
> this.matrikelnr = matrikelnummer;
> }
> /**
> *
> * @return
> * @hibernate.property
> */
> public Long getEjerlavskode() {
> return ejerlavskode;
> }
> public void setEjerlavskode(Long ejerlavskode) {
> this.ejerlavskode = ejerlavskode;
> }
> /**
> *
> * @return
> * @hibernate.property length="20"
> */
> public String getMatrikelnr() {
> return matrikelnr;
> }
> public void setMatrikelnr(String matrikelnr) {
> this.matrikelnr = matrikelnr;
> }
> public boolean equals(Object o) {
> if (this == o) return true;
> if (!(o instanceof Matrikelbetegnelse)) return false;
> final Matrikelbetegnelse matrikelbetegnelse = (Matrikelbetegnelse) o;
> if (!ejerlavskode.equals(matrikelbetegnelse.ejerlavskode)) return false;
> if (!matrikelnr.equals(matrikelbetegnelse.matrikelnr)) return false;
> return true;
> }
> public int hashCode() {
> int result;
> result = ejerlavskode.hashCode();
> result = 29 * result + matrikelnr.hashCode();
> return result;
> }
> }
> Full stack trace of any exception that occurs:
> No exception, just an empty result.
> Name and version of the database you are using:
> Oracle 10g Enteprise Edition release 10.1.0.2.0
> The generated SQL (show_sql=true):
> Hibernate: select this_.id as id34_0_, this_.datoTid as datoTid34_0_, this_.ejerlavskode as ejerlavs3_34_0_, this_.matrikelnr as matrikelnr34_0_, this_.fk_sag_id as fk5_34_0_, this_.brugerId as brugerId34_0_, this_.tidsstempel as tidsstem7_34_0_, this_.gyldig_fra as gyldig8_34_0_, this_.gyldig_til as gyldig9_34_0_, this_.oprind_id as oprind10_34_0_ from tan.sagsadvarsel this_ where (this_.ejerlavskode, this_.matrikelnr) in ((?, ?), (?, ?))
> Debug level Hibernate log excerpt:
> 14:02:58,631 DEBUG [CID= ] [org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:346)] select this_.id as id34_1_, this_.version as version34_1_, this_.datoTid as datoTid34_1_, this_.ejerlavskode as ejerlavs4_34_1_, this_.matrikelnr as matrikelnr34_1_, this_.fk_sag_id as fk6_34_1_, this_.brugerId as brugerId34_1_, this_.tidsstempel as tidsstem8_34_1_, this_.gyldig_fra as gyldig9_34_1_, this_.gyldig_til as gyldig10_34_1_, this_.oprind_id as oprind11_34_1_, s1_.id as id15_0_, s1_.version as version15_0_, s1_.sagsId as sagsId15_0_, s1_.symbolskNavn as symbolsk4_15_0_, s1_.kms_journalnummer as kms5_15_0_, s1_.journaliseringsDato as journali6_15_0_, s1_.rekvirentRef as rekviren7_15_0_, s1_.enum_sagskategori as enum8_15_0_, s1_.enum_prioritet as enum9_15_0_, s1_.tidsfrist as tidsfrist15_0_, s1_.saerligAftale as saerlig11_15_0_, s1_.matrikelnr as matrikelnr15_0_, s1_.ejerlavskode as ejerlav13_15_0_, s1_.afventAntalHoeringssvar as afventA14_15_0_, s1_.afventAntalSupplDok as afventA15_15_0_, s1_.maaIkkeSlettes as maaIkke16_15_0_, s1_.erForaeldet as erForae17_15_0_, s1_.brugerId as brugerId15_0_, s1_.tidsstempel as tidsste19_15_0_, s1_.gyldig_fra as gyldig20_15_0_, s1_.gyldig_til as gyldig21_15_0_, s1_.oprind_id as oprind22_15_0_, s1_.fk_aktoer_indsender_id as fk23_15_0_, s1_.fk_aktoer_rekvirent_id as fk24_15_0_, s1_.fk_aktoer_revisor_id as fk25_15_0_, s1_.fk_sagsbehandlerteam_id as fk26_15_0_, s1_.fk_sagspakke_id as fk27_15_0_, s1_.fk_sagsresume_id as fk28_15_0_, s1_.aflysningsmeddelelse as aflysni29_15_0_, s1_.fk_samlesag_id as fk30_15_0_ from tan.sagsadvarsel this_ inner join tan.sag s1_ on this_.fk_sag_id=s1_.id where (this_.ejerlavskode, this_.matrikelnr) in ((?, ?), (?, ?)) and not s1_.sagsId=? order by this_.fk_sag_id asc, this_.ejerlavskode asc, this_.matrikelnr asc
> Hibernate: select this_.id as id34_1_, this_.version as version34_1_, this_.datoTid as datoTid34_1_, this_.ejerlavskode as ejerlavs4_34_1_, this_.matrikelnr as matrikelnr34_1_, this_.fk_sag_id as fk6_34_1_, this_.brugerId as brugerId34_1_, this_.tidsstempel as tidsstem8_34_1_, this_.gyldig_fra as gyldig9_34_1_, this_.gyldig_til as gyldig10_34_1_, this_.oprind_id as oprind11_34_1_, s1_.id as id15_0_, s1_.version as version15_0_, s1_.sagsId as sagsId15_0_, s1_.symbolskNavn as symbolsk4_15_0_, s1_.kms_journalnummer as kms5_15_0_, s1_.journaliseringsDato as journali6_15_0_, s1_.rekvirentRef as rekviren7_15_0_, s1_.enum_sagskategori as enum8_15_0_, s1_.enum_prioritet as enum9_15_0_, s1_.tidsfrist as tidsfrist15_0_, s1_.saerligAftale as saerlig11_15_0_, s1_.matrikelnr as matrikelnr15_0_, s1_.ejerlavskode as ejerlav13_15_0_, s1_.afventAntalHoeringssvar as afventA14_15_0_, s1_.afventAntalSupplDok as afventA15_15_0_, s1_.maaIkkeSlettes as maaIkke16_15_0_, s1_.erForaeldet as erForae17_15_0_, s1_.brugerId as brugerId15_0_, s1_.tidsstempel as tidsste19_15_0_, s1_.gyldig_fra as gyldig20_15_0_, s1_.gyldig_til as gyldig21_15_0_, s1_.oprind_id as oprind22_15_0_, s1_.fk_aktoer_indsender_id as fk23_15_0_, s1_.fk_aktoer_rekvirent_id as fk24_15_0_, s1_.fk_aktoer_revisor_id as fk25_15_0_, s1_.fk_sagsbehandlerteam_id as fk26_15_0_, s1_.fk_sagspakke_id as fk27_15_0_, s1_.fk_sagsresume_id as fk28_15_0_, s1_.aflysningsmeddelelse as aflysni29_15_0_, s1_.fk_samlesag_id as fk30_15_0_ from tan.sagsadvarsel this_ inner join tan.sag s1_ on this_.fk_sag_id=s1_.id where (this_.ejerlavskode, this_.matrikelnr) in ((?, ?), (?, ?)) and not s1_.sagsId=? order by this_.fk_sag_id asc, this_.ejerlavskode asc, this_.matrikelnr asc
> 14:02:58,641 DEBUG [CID= ] [org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:424)] preparing statement
> 14:02:58,641 DEBUG [CID= ] [org.hibernate.type.NullableType.nullSafeSet(NullableType.java:79)] binding '9999' to parameter: 1
> 14:02:58,641 DEBUG [CID= ] [org.hibernate.type.NullableType.nullSafeSet(NullableType.java:79)] binding '9999' to parameter: 2
> 14:02:58,641 DEBUG [CID= ] [org.hibernate.type.NullableType.nullSafeSet(NullableType.java:79)] binding '01' to parameter: 3
> 14:02:58,641 DEBUG [CID= ] [org.hibernate.type.NullableType.nullSafeSet(NullableType.java:79)] binding '03' to parameter: 4
> 14:02:58,701 DEBUG [CID= ] [org.hibernate.jdbc.AbstractBatcher.logOpenResults(AbstractBatcher.java:327)] about to open ResultSet (open ResultSets: 0, globally: 0)
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2827) RuntimeException from Connection.rollback/setAutoCommit Corrupts SessionFactory (on a per thread basis)
by Mihai Danila (JIRA)
RuntimeException from Connection.rollback/setAutoCommit Corrupts SessionFactory (on a per thread basis)
-------------------------------------------------------------------------------------------------------
Key: HHH-2827
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2827
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.1.3
Environment: 3.1.3, WebLogic on Windows, DB2 JDBC Driver, DB2 UDB on Windows
Reporter: Mihai Danila
Attachments: HibernateClosedSessionBug.zip
When java.sql.Connection's rollback/setAutoCommit methods throw a RuntimeException, as is the case in some circumstances in WebLogic, the SessionFactory fails to correctly clean up the session.
The problem is in class org.hibernate.transaction.JDBCTransaction, lines 161-177. The block only raises afterTransactionCompletion if (a) the rollback operation within the try block succeeds or (b) the rollback operation fails with an SQLException. This is wrong, as reproduced by us in a WebLogic 8.1.3 environment, by causing a database outage at just the right time.
The net effect is that the session cleanup does not occur, and all subsequent attempts to use currentSession() on the same transaction factory from the same thread will fail miserably.
The fact that WebLogic raises a RuntimeException in case of a database outage is a WebLogic bug that we raised with them. However, according to Sun's document on Javadoc comments, (http://java.sun.com/j2se/javadoc/writingdoccomments/#throwstag) Hibernate should guard against an unchecked exception and still cleanup properly.
"Since there is no way to guarantee that a call has documented all of the unchecked exceptions that it may throw, the programmer must not depend on the presumption that a method cannot throw any unchecked exceptions other than those that it is documented to throw. In other words, you should always assume that a method can throw unchecked exceptions that are undocumented."
Attached is sample code that shows the problem. I believe the solution is to remove the fire event call from the try/catch blocks and add it into the finally block, guarding it with its own finally block, if necessary:
Instead of:
try {
rollbackAndResetAutoCommit();
log.debug("rolled back JDBC Connection");
rolledBack = true;
afterTransactionCompletion(Status.STATUS_ROLLEDBACK);
}
catch (SQLException e) {
log.error("JDBC rollback failed", e);
afterTransactionCompletion(Status.STATUS_UNKNOWN);
throw new TransactionException("JDBC rollback failed", e);
}
finally {
if ( callback ) {
jdbcContext.afterTransactionCompletion( false, this );
}
closeIfRequired();
}
It would be:
try {
rollbackAndResetAutoCommit();
log.debug("rolled back JDBC Connection");
rolledBack = true;
}
catch (SQLException e) {
log.error("JDBC rollback failed", e);
throw new TransactionException("JDBC rollback failed", e);
}
finally {
afterTransactionCompletion(rolledBack ? Status.STATUS_ROLLEDBACK : Status.STATUS_UNKNOWN);
if ( callback ) {
jdbcContext.afterTransactionCompletion( false, this );
}
closeIfRequired();
}
--
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, 8 months