[Hibernate-JIRA] Created: (ANN-625) @OrderBy usage on a joined classes (when using join table) produces incorred SQL syntax.
by Dima Gutzeit (JIRA)
@OrderBy usage on a joined classes (when using join table) produces incorred SQL syntax.
----------------------------------------------------------------------------------------
Key: ANN-625
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-625
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga
Reporter: Dima Gutzeit
Please consider the following mapping :
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
@IndexColumn(name = "ListIndex")
@JoinTable(name = "odp_rulemanipulatorjoin", joinColumns = @JoinColumn(name = "RoutingRuleId"), inverseJoinColumns = @JoinColumn(name = "ManipulatorComponentId"))
@OrderBy(value = "priority asc")
public List<RoutingManipulationComponent> getManipulators() {
if (manipulators == null) {
manipulators = new ArrayList<RoutingManipulationComponent>();
}
return manipulators;
}
***********************************
@Entity(name = "RoutingManipulationComponent")
@DiscriminatorValue("RoutingManipulationComponent")
public abstract class RoutingManipulationComponent extends RoutingComponent implements Initializable {
/**
* Applies the manipulation to the given context.
*
* @param context the routing context to manipulate
* @return true if any manipulation was applied, false if no manipulation
* occurred
*/
public abstract boolean apply(RoutingContext context);
}
******************************************
@Entity(name = "RoutingComponent")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "RoutingComponentType", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("RoutingComponent")
@Table(name = "odp_routingcomponent")
public abstract class RoutingComponent extends DialPlanProvisionalEntity {
@Deprecated
public RoutingComponent() {
// blank
}
/**
* @param name
* @param description
*/
public RoutingComponent(String name, String description) {
super(name, description);
}
}
*******************************
@MappedSuperclass
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public abstract class DialPlanProvisionalEntity extends ProvisionalEntity
implements Initializable {
private Long entityId;
private boolean visible = true;
private int priority;
/**
* Not for direct instantiation - this constructor also serves as public
* constructor for hibernate, jax-ws etc. <br>
*/
@Deprecated
public DialPlanProvisionalEntity() {
this("(no name set)", "(no description set)");
}
/**
* @param name
* @param description
*/
public DialPlanProvisionalEntity(String name, String description) {
creationDate = GregorianCalendar.getInstance(); // now
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Override
public Long getId() {
return entityId;
}
@Override
public void setId(Long ruleCollectionId) {
this.entityId = ruleCollectionId;
}
/**
* @return Returns the priority.
*/
public int getPriority() {
return priority;
}
/**
* @param priority The priority to set.
*/
public void setPriority(int priority) {
this.priority = priority;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
return false;
}
final ProvisionalEntity other = (ProvisionalEntity) o;
return MiscUtils.equalOrBothNull(this.getName(), other.getName());
}
@Override
public int hashCode() {
String name = this.getName();
return getClass().getName().hashCode() + 13 * name.hashCode();
}
}
The above mapping should use the "priority" field to the ordering.
SQL that is produced is :
select criteria0_.RoutingRuleId as RoutingR1_1_, criteria0_.CriteriaComponentId as Criteria2_1_,
criteria0_.ListIndex as ListIndex1_,
routingcri1_.id as id73_0_,
routingcri1_.creationDate as creation3_73_0_,
routingcri1_.description as descript4_73_0_,
routingcri1_.lastModificationDate as lastModi5_73_0_,
routingcri1_.name as name73_0_,
routingcri1_.predefined as predefined73_0_,
routingcri1_.status as status73_0_,
routingcri1_.priority as priority73_0_,
routingcri1_.visible as visible73_0_,
routingcri1_.matcher_id as matcher25_73_0_,
routingcri1_.criterion_id as criterion27_73_0_,
routingcri1_.location_id aslocation26_73_0_,
routingcri1_.RoutingComponentType as RoutingC1_73_0_
from odp_rulecriteriajoin criteria0_
left outer join odp_routingcomponent as routingcri1_ on criteria0_.CriteriaComponentId=routingcri1_.id
where criteria0_.RoutingRuleId=1 order by odp_routingcomponent .priority asc
It is wrong since not the table alias is used in the order by clause, but the real table name.
Mysql fails with exception that odp_rulecriteriajoin.priority is unknown table.
Changing the query to include "order by criteria0_.priority asc" returns the correct result.
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-2158) incorrect hql query on one-to-one with property-ref
by Sebastien Cesbron (JIRA)
incorrect hql query on one-to-one with property-ref
----------------------------------------------------
Key: HHH-2158
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2158
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: hibernate 3.2.0.ga with firebird 1.5.3 and jaybird 1.5.5 driver on windows XP
Reporter: Sebastien Cesbron
Attachments: testhib.zip
I have a one-to-one relationship with property-ref between Master and Slave2.
I want to find all Master instances that have a null Slave2 instance associated.
To do so my query is
select master from Master master where master.slave2 is null
The sql generated is
select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_ where master0_.oid is null
which seems incorrect. It checks here Master instances with null id (config files are listed below).
If I do my query like this
select master from Master master where master.slave2.oid is null
the generated sql is ok :
select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_, Slave2 slave2x1_ where master0_.oid=slave2x1_.myMaster and (slave2x1_.oid is null)
I have attached a small eclipse project that reproduces the problem
This problem may-be related to the one I have submitted as issue HHH-1849
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HBX-948) org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
by Sathish P (JIRA)
org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
--------------------------------------------------------------------------------------------
Key: HBX-948
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-948
Project: Hibernate Tools
Issue Type: Bug
Components: consoleconfiguration
Affects Versions: 3.1.beta5
Environment: Eclipse
Reporter: Sathish P
WARN Finalizer org.hibernate.connection.DriverManagerConnectionProvider - problem closing pooled connection
java.sql.SQLException: Io exception: Socket closed
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:481)
at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:1203)
at org.hibernate.connection.DriverManagerConnectionProvider.close(DriverManagerConnectionProvider.java:152)
at org.hibernate.connection.DriverManagerConnectionProvider.finalize(DriverManagerConnectionProvider.java:142)
at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
at java.lang.ref.Finalizer.access$100(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-2666) subselect fetching ignores max results
by James Roper (JIRA)
subselect fetching ignores max results
--------------------------------------
Key: HHH-2666
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2666
Project: Hibernate3
Issue Type: Improvement
Components: query-hql, query-sql
Affects Versions: 3.2.1
Environment: Hibernate 3.2.1
HSQLDB 8.0
Reporter: James Roper
Priority: Minor
When maxResults is set for a query, the hibernate subselect fetching strategy ignores it. For example, I have a class entry, that has a list of comments, which are configured to use the subselect fetching strategy. You can see that in the original query, only the top ? results are fetched:
select
top ? entry0_.id as id0_,
entry0_.title as title0_,
entry0_.entry as entry0_,
entry0_.time as time0_,
entry0_.category_id as category5_0_
from
Entry entry0_
order by
entry0_.time desc
But then when it does the sub select query to lazily load the comments, this is the query it runs:
select
comments0_.entry_id as entry5_1_,
comments0_.id as id1_,
comments0_.id as id1_0_,
comments0_.time as time1_0_,
comments0_.comment as comment1_0_,
comments0_.author as author1_0_
from
Comment comments0_
where
comments0_.entry_id in (
select
entry0_.id
from
Entry entry0_
)
order by
comments0_.time desc
So, it loads every single comment in the database, even though only the comments for the top ? entries are needed. Of course, if there was no order by clause on the first query, the sub select may not return the same results, so it should probably only do this when there is an order by clause in the first query, and it should make sure it includes the order by clause in the sub select.
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (ANN-609) Need a way to specify "unsaved-value" strategy using annotations
by Suji Suresh (JIRA)
Need a way to specify "unsaved-value" strategy using annotations
----------------------------------------------------------------
Key: ANN-609
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-609
Project: Hibernate Annotations
Issue Type: Bug
Environment: Hibernate 3.2.2, Hibernate-annotations 3.2.1
Reporter: Suji Suresh
Hibernate has two ways of specifying a value for primary key:
1. Assign a value before handing it over to Hibernate
2. Have Hibernate generate the value before persisting
In my project I have objects of both of the above specified types. In other words I assign value for the primary key for some the objects (lets call these objects "assigned") and for others I have Hibernate generate the value before persisting (lets call these objects "generated"). Since Hibernate annotations does not support "unsaved-value", I do not have a way of specifying "unsaved-value" strategy. While my "generated" objects work perfectly with Hibernate's default "unsaved-value" strategy, I see wrong (but expected) behaviour when I try to persist an "assigned" object that is already present in the database in that, I get StaleStateException instead of DataIntegrityViolationException
--
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
12 years, 5 months
[Hibernate-JIRA] Created: (HHH-3724) Bug in determining the getter method for property
by Senthil (JIRA)
Bug in determining the getter method for property
--------------------------------------------------
Key: HHH-3724
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3724
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: hibernate-core-3.3.1.GA.jar, Oracle Express Edition 10g
Reporter: Senthil
Priority: Minor
I have an entity class with a property "String nextOnError" mapping to the database column "varchar nextOnError". I have a getter method "String getNextOnError()" defined in the class. But I also have another method "boolean isNextOnError()" for my other processing in the application. I was expecting hibernate would pick the getter method "String getNextOnError()" as the getter method but it is not. It is always picking the "boolean isNextOnError()" and resulting in "Class cast exception: java.lang.Boolean" during insertion. This is because, for each property, in the class "org.hibernate.property.BasicPropertyAccessor", the method "getterMethod(Class theClass, String propertyName)" is looping through all the getter methods with no arguments. The loop breaks when it finds any method starts with either "isNextOnError()" or "getNextOnError()". Unfortunately, in my case, it always ends up with "boolean isNextOnError()". I think the correct way is to check all the methods for starting with get... and if nothing is found, then start looking for method starting with 'is...' .
Thanks.
--
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
12 years, 6 months
[Hibernate-JIRA] Created: (HHH-3500) Hibernate fails to resolve the correct orderby column in SQL when using inheritance hierarchy
by Joonas Koivunen (JIRA)
Hibernate fails to resolve the correct orderby column in SQL when using inheritance hierarchy
---------------------------------------------------------------------------------------------
Key: HHH-3500
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3500
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.0.GA
Environment: Derby 10.4.2.0 (http://db.apache.org)
Reporter: Joonas Koivunen
I have an inheritance hierarchy:
@Entity("abstractBaseClass")
AbstractBaseClass
- ConcreteClass1
- ConcreteClass2
- ConcreteClass3
AbstractBaseClass has:
- @Id long id;
- String name;
@Entity("concreteClass1") ConcreteClass1 has a @OneToMany(mappedBy="concreteClass1") List<ConcreteClass2>
@Entity("concreteClass2") ConcreteClass2 has a @OneToMany(mappedBy="concreteClass2") List<ConcreteClass3> and a reference to @ManyToOne ConcreteClass1.
@Entity("concreteClass3") ConcreteClass3 has a reference to @ManyToOne ConcreteClass2.
After adding a @OrderBy("name") annotation to the getter "List<ConcreteClass3> ConcreteClass2.getConcreteClass3s()" and afterwards accessing the association through an ConcreteClass2 instance I get:
SELECT
cc3_concrete.cc2_id,
cc3_concrete.id,
cc3_base.name,
cc3_concrete.cc2_id AS cc2_id_2
FROM
cc3 cc3_concrete
INNER JOIN
abstractBaseClass cc3_base ON cc3_concrete.id = cc3_base.id
WHERE
cc3_concrete.cc2_id = ?
ORDER BY
abstractBaseClass.name asc
(I edited hibernate's naming of entities in SQL to be a bit more clearer).
Ordering by "abstractBaseClass.name" causes the problem here; it's obvious that it should had been "cc3_base.name" but for some reason hib just uses the entityname.column_name in the SQL.
Another strange thing is that the foreign key column "cc2_id" is being included twice in the results? It is included in the select wheter or not @OrderBy exists.
Inheritance strategy used is javax.persistence.InheritanceType.JOINED.
--
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
12 years, 6 months
[Hibernate-JIRA] Created: (HHH-3300) HQL looks for property in wrong class and reports "could not resolve property"
by Cristian Bogdan (JIRA)
HQL looks for property in wrong class and reports "could not resolve property"
------------------------------------------------------------------------------
Key: HHH-3300
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3300
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6.ga, mysql 5.0.37
Reporter: Cristian Bogdan
could not resolve property: groupMembers of: projman.Project
[SELECT it.project.color AS col1 FROM projman.Deficienta def JOIN def.item it WHERE exists (FROM it.project.participants grp JOIN grp.groupMembers p WHERE p=:principal )
)) ORDER BY it.end]
the problem is, groupMembers is not a property of projman.Project, but a bag in projman,Principal.
as soon as I replace the it.project.color projection with e.g. it.start (i.e. i don't make any other join with projman.Project), the query works.
the original query is actually more complicated but i reduced my test to the above for simplicity. rewriting the query without subqueries is not an option.
i paste the relevant (generated) mappings.
<hibernate-mapping auto-import="false">
<class name="projman.Project" table="projman_Project_">
<id name="primaryKey" column="Project_">
<generator class="identity"/>
</id>
<property name="TS_modify" column="TS_modify_"/>
<property name="TS_create" column="TS_create_"/>
<property name="name">
<column name="name_" length="255"/>
</property>
<bag name="participants" table="projman_Project__participants_" cascade="all" inverse="false">
<key column="Project_"/>
<many-to-many class="projman.Principal" column="Principal_"/>
</bag>
<many-to-one name="beneficiar" column="beneficiar_" cascade="all" class="projman.Company"/>
<many-to-one name="generalDesigner" column="generalDesigner_" cascade="all" class="projman.Compa
ny"/>
<bag name="signExecution" table="projman_Project__signExecution_" cascade="all" inverse="false">
<key column="Project_"/>
<many-to-many class="projman.Company" column="Company_"/>
</bag>
<property name="color">
<column name="color_" length="6"/>
</property>
</class>
</hibernate-mapping>
<hibernate-mapping auto-import="false">
<class name="projman.Principal" table="projman_Principal_">
<id name="primaryKey" column="Principal_">
<generator class="identity"/>
</id>
<property name="TS_modify" column="TS_modify_"/>
<property name="TS_create" column="TS_create_"/>
<property name="kind" column="kind_"/>
<bag name="groupMembers" table="projman_Principal__groupMembers_" cascade="all" inverse="false">
<key column="Principal_"/>
<many-to-many class="projman.Principal" column="Principal__"/>
</bag>
<property name="displayName">
<column name="displayName_" length="255"/>
</property>
</class>
</hibernate-mapping>
<hibernate-mapping auto-import="false">
<class name="projman.Deficienta" table="projman_Deficienta_">
<id name="primaryKey" column="Deficienta_">
<generator class="identity"/>
</id>
<property name="TS_modify" column="TS_modify_"/>
<property name="TS_create" column="TS_create_"/>
<many-to-one name="item" column="item_" cascade="all" class="projman.Item"/>
<many-to-one name="firma" column="firma_" cascade="all" class="projman.Company"/>
<bag name="alteFirme" table="projman_Deficienta__alteFirme_" cascade="all" inverse="false">
<key column="Deficienta_"/>
<many-to-many class="projman.Company" column="Company_"/>
</bag>
<property name="amenda" column="amenda_"/>
</class>
</hibernate-mapping>
<hibernate-mapping auto-import="false">
<class name="projman.Item" table="projman_Item_">
<id name="primaryKey" column="Item_">
<generator class="identity"/>
</id>
<property name="TS_modify" column="TS_modify_"/>
<property name="TS_create" column="TS_create_"/>
<many-to-one name="project" column="project_" cascade="all" class="projman.Project"/>
<property name="type" column="type_"/>
<bag name="toWhom" table="projman_Item__toWhom_" cascade="all" inverse="false">
<key column="Item_"/>
<many-to-many class="projman.Principal" column="Principal_"/>
</bag>
<property name="subject">
<column name="subject_" length="255"/>
</property>
<property name="description" type="org.makumba.db.hibernate.TextUserType">
<column name="description_" sql-type="longtext"/>
</property>
<many-to-one name="creator" column="creator_" cascade="all" class="projman.Principal"/>
<property name="creationDate" column="creationDate_"/>
<property name="start" column="start_"/>
<property name="end" column="end_"/>
<bag name="events" inverse="true" cascade="none">
<key column="Item_"/>
<one-to-many class="projman.Item__events"/>
</bag>
<bag name="attachments" table="projman_Item__attachments_" cascade="all" inverse="false">
<key column="Item_"/>
<many-to-many class="projman.Document" column="Document_"/>
</bag>
</class>
</hibernate-mapping>
--
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
12 years, 6 months
[Hibernate-JIRA] Created: (EJB-363) @OrderBy applied to collection property of derived class does not work properly when column used for ordering belongs to base class (using MySQL 5)
by Rich Eggert (JIRA)
@OrderBy applied to collection property of derived class does not work properly when column used for ordering belongs to base class (using MySQL 5)
---------------------------------------------------------------------------------------------------------------------------------------------------
Key: EJB-363
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-363
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.3.2.GA
Environment: MySQL 5.0.18, Hibernate Core 3.2.6, Hibernate EntityManager 3.3.2, and the MySQL5InnoDBDialect.
Test run with Tomcat 6.0.16 (Sun JDK 1.6.0_06) and Spring Framework 2.5.3.
Relying on Hibernate automatic DDL generation (hibernate.hbm2ddl.auto=update), which appears to be working properly.
Reporter: Rich Eggert
Attachments: SampleBase.java, SampleDerived.java, SampleServiceImpl.java
I applied the (JPA) @OrderBy annotation to a collection of entities belonging to an entity class (named SampleDerived in the attached sample code) of the same type (i.e., the class has a one-to-many parent-child relationship to itself). The property name passed as the argument to the @OrderBy annotation refers to a property of the base class (named SampleBase in the example), which employs the "JOINED" inheritence strategy.
When I attempted to access the collection of a persisted instance of the entity class (in the example, this is accomplished by calling SampleServiceImpl.createSample() followed by calling SampleServiceImpl.findChildren() against the return value), the following (root cause) exception is generated:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'SampleBase.timestamp' in 'order clause'
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266)
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
org.hibernate.loader.Loader.doQuery(Loader.java:674)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63)
org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:249)
org.frecklepuppy.bb.service.impl.SampleServiceImpl.findChildren(SampleServiceImpl.java:52)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy209.findChildren(Unknown Source)
org.frecklepuppy.bb.ui.controllers.IndexController.listForums(IndexController.java:66)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:413)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:134)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:310)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:297)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:523)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:453)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:359)
org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:109)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:172)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:268)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:87)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:68)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.securechannel.ChannelProcessingFilter.doFilterHttp(ChannelProcessingFilter.java:116)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:371)
org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:174)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:183)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:138)
I verified (using MySQL Administrator) that the SampleBase.timestamp column does, in fact, exist. According to the org.hibernate.SQL log, the offending SQL statement looks like this:
select children0_.parent_id as parent2_1_, children0_.id as id1_, children0_.id as id5_0_, children0_1_.timestamp as timestamp5_0_, children0_.parent_id as parent2_6_0_ from SampleDerived children0_ inner join SampleBase children0_1_ on children0_.id=children0_1_.id where children0_.parent_id=? order by SampleBase.timestamp asc
I believe the problem is that MySQL 5 requires that the alias for the base class table used in the FROM clause (children0_1_ in this case) be used in the ORDER BY clause, instead of the actual name of the base class table. After browsing various MySQL discussions, it appears this is new to MySQL 5 (versus 4 or earlier) and was done in order to be more standards compliant.
It's unclear to me whether this affects Hibernate Core or is limited to EntityManager. I'll try to narrow down the problem further as time permits (which it isn't likely to do any time soon).
--
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
12 years, 6 months
[Hibernate-JIRA] Created: (HHH-3577) Wrong SQL in order by clause when using joined subclasses
by Hardy Ferentschik (JIRA)
Wrong SQL in order by clause when using joined subclasses
---------------------------------------------------------
Key: HHH-3577
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3577
Project: Hibernate Core
Issue Type: Bug
Components: core
Reporter: Hardy Ferentschik
Assignee: Steve Ebersole
The changes for HHH-2802 seem to have broken the following tests in Annotations:
* ManyToManyTest.testOrderByContractor()
* OneToManyTest.testOrderByOnSuperclassProperty()
Prior to the changes for HHH-2802 no table aliases where generated for in the SQL for these tests. Since it is generally a problem to generate the right table alias in case of joined subclasses there is a workaround in CollectionBinder.buildOrderByClauseFromHql() line 910 where the table name is explicitly set in the oder by clause. This workaround together with the changes for HHH-2802 now generate illegal SQL, eg:
select
contractor0_.EMPLOYER_ID as EMPLOYER1_1_,
contractor0_.CONTRACTOR_ID as CONTRACTOR2_1_,
contractor1_.id as id2_0_,
contractor1_1_.fld_name as fld2_2_0_,
contractor1_.hourlyRate as hourlyRate3_0_
from
EMPLOYER_CONTRACTOR contractor0_
left outer join
Contractor contractor1_
on contractor0_.CONTRACTOR_ID=contractor1_.id
left outer join
Employee contractor1_1_
on contractor1_.id=contractor1_1_.id
where
contractor0_.EMPLOYER_ID=?
order by
contractor1_.Employee.fld_name desc
Hibernate:
select
contractor0_.EMPLOYER_ID as EMPLOYER1_1_,
contractor0_.CONTRACTOR_ID as CONTRACTOR2_1_,
contractor1_.id as id2_0_,
contractor1_1_.fld_name as fld2_2_0_,
contractor1_.hourlyRate as hourlyRate3_0_
from
EMPLOYER_CONTRACTOR contractor0_
left outer join
Contractor contractor1_
on contractor0_.CONTRACTOR_ID=contractor1_.id
left outer join
Employee contractor1_1_
on contractor1_.id=contractor1_1_.id
where
contractor0_.EMPLOYER_ID=?
order by
contractor1_.Employee.fld_name desc
In this case 'contractor1_' is generated by the changes made for HHH-2802 whereas 'Employee' is added by the workaround. Note that even though Employee is not working for all databases, the generated alias is wrong and should be 'contractor1_1_.
For now I commented out the failing tests since I cannot use the test skipping functionality in Annotations yet.
--
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
12 years, 6 months