[Hibernate-JIRA] Created: (HSEARCH-1087) Synchronization during JTA afterCompletion() incompatible with Hibernate-Core
by Eli Colner (JIRA)
Synchronization during JTA afterCompletion() incompatible with Hibernate-Core
-----------------------------------------------------------------------------
Key: HSEARCH-1087
URL: https://hibernate.onjira.com/browse/HSEARCH-1087
Project: Hibernate Search
Issue Type: Bug
Components: engine
Affects Versions: 4.0.0.Final
Reporter: Eli Colner
Priority: Critical
During synchronization Hibernate Core's SessionImpl.close() calls org.hibernate.engine.transaction.internal.TransactionCoordinator.close() which in-turns calls org.hibernate.engine.transaction.internal.TransactionCoordinator.reset(). During the reset the transactionCoordinator calls org.hibernate.engine.transaction.internal.SynchronizationRegistry.clearSynchronizations(). The synchronizations list is emptied and nulled. This removes the BeforeCommitSynchronizationDelegator instance that was registered from org.hibernate.search.backend.impl.EventSourceTransactionContext.registerSynchronization() during the JTA transaction. Clearing the synchronization list causes a ConcurrentModificationException to be thrown from org.hibernate.search.backend.impl.SynchronizationRegistryImpl.notifySynchronizationsAfterTransactionCompletion() because it is iterating the synchronization list and at the start it contains two Synchronization instances in this order (EntityManagerImpl.Synchronization, BeforeCommitSynchronizationDelegator). So, basically the first Synchronization is removing the second Synchronization while in a loop...
ARJUNA016029: SynchronizationImple.afterCompletion - failed for org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization@192e31c with exception
java.util.ConcurrentModificationException
at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(LinkedHashMap.java:373)
at java.util.LinkedHashMap$KeyIterator.next(LinkedHashMap.java:384)
at org.hibernate.engine.transaction.internal.SynchronizationRegistryImpl.notifySynchronizationsAfterTransactionCompletion(SynchronizationRegistryImpl.java:78)
at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.sendAfterTransactionCompletionNotifications(TransactionCoordinatorImpl.java:335)
at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.afterTransaction(TransactionCoordinatorImpl.java:147)
at org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl.afterCompletion(SynchronizationCallbackCoordinatorImpl.java:126)
at org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.afterCompletion(RegisteredSynchronization.java:61)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.afterCompletion(SynchronizationImple.java:117)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.afterCompletion(TwoPhaseCoordinator.java:403)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:104)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:159)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1162)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:119)
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1010)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months
[Hibernate-JIRA] Created: (HSEARCH-1095) Near Real Time + RAM seems to not work
by Emmanuel Bernard (JIRA)
Near Real Time + RAM seems to not work
--------------------------------------
Key: HSEARCH-1095
URL: https://hibernate.onjira.com/browse/HSEARCH-1095
Project: Hibernate Search
Issue Type: Bug
Components: engine
Reporter: Emmanuel Bernard
Assignee: Sanne Grinovero
{code}
13:34:02,078 ERROR [org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask] (Hibernate Search: Index updates queue processor for index org.jboss.as.quickstarts.kitchensink.model.Member-1) HSEARCH000073: Error in backend: java.lang.NullPointerException
at org.hibernate.search.backend.impl.lucene.NRTWorkspaceImpl.flush(NRTWorkspaceImpl.java:171) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.search.backend.impl.lucene.NRTWorkspaceImpl.afterTransactionApplied(NRTWorkspaceImpl.java:79) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.applyUpdates(LuceneBackendQueueTask.java:138) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.run(LuceneBackendQueueTask.java:67) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [classes.jar:1.6.0_31]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [classes.jar:1.6.0_31]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [classes.jar:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_31]
at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_31]
13:34:02,099 ERROR [org.hibernate.search.exception.impl.LogErrorHandler] (Hibernate Search: Index updates queue processor for index org.jboss.as.quickstarts.kitchensink.model.Member-1) HSEARCH000058: Exception occurred java.lang.NullPointerException
Primary Failure:
Entity org.jboss.as.quickstarts.kitchensink.model.Member Id 1 Work Type org.hibernate.search.backend.AddLuceneWork
Subsequent failures:
Entity org.jboss.as.quickstarts.kitchensink.model.Member Id 2 Work Type org.hibernate.search.backend.AddLuceneWork
Entity org.jboss.as.quickstarts.kitchensink.model.Member Id 3 Work Type org.hibernate.search.backend.AddLuceneWork
Entity org.jboss.as.quickstarts.kitchensink.model.Member Id 4 Work Type org.hibernate.search.backend.AddLuceneWork
java.lang.NullPointerException
at org.hibernate.search.backend.impl.lucene.NRTWorkspaceImpl.flush(NRTWorkspaceImpl.java:171) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.search.backend.impl.lucene.NRTWorkspaceImpl.afterTransactionApplied(NRTWorkspaceImpl.java:79) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.applyUpdates(LuceneBackendQueueTask.java:138) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.run(LuceneBackendQueueTask.java:67) [hibernate-search-engine-4.1.0.Final.jar:4.1.0.Final]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [classes.jar:1.6.0_31]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [classes.jar:1.6.0_31]
at java.util.concurrent.FutureTask.run(FutureTask.java:138) [classes.jar:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [classes.jar:1.6.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [classes.jar:1.6.0_31]
at java.lang.Thread.run(Thread.java:680) [classes.jar:1.6.0_31]
{code}
{code}@Entity
@XmlRootElement
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "email"))
@Indexed
public class Member implements Serializable {
/** Default value included to remove warning. Remove or modify at will. **/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@NotNull
@Size(min = 1, max = 25)
@Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
@Field
private String name;
@NotNull
@NotEmpty
@Email
private String email;
@NotNull
@Size(min = 10, max = 12)
@Digits(fraction = 0, integer = 12)
@Column(name = "phone_number")
private String phoneNumber;
@NotEmpty
@Size(min = 2, max = 50)
@Field
private String location;
@NotEmpty
@Size(min = 2, max = 50)
@Field
private String job;
{code}
{code}<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="primary">
<!-- If you are running in a production environment, add a managed
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as WEB-INF/kitchensink-quickstart-ds.xml, you
can find it in the source at src/main/webapp/WEB-INF/kitchensink-quickstart-ds.xml -->
<jta-data-source>java:jboss/datasources/KitchensinkQuickstartDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.search.default.indexmanager" value="near-real-time"/>
<property name="hibernate.search.default.directory_provider" value="ram"/>
</properties>
</persistence-unit>
</persistence>
{code}
When I comment <property name="hibernate.search.default.indexmanager" value="near-real-time"/>, it works
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 months
[Hibernate-JIRA] Created: (HHH-4504) Query on polyphomic association
by Rafael Santini (JIRA)
Query on polyphomic association
-------------------------------
Key: HHH-4504
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4504
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: MySQL 5.0.51a-community-nt
Reporter: Rafael Santini
The following query on a polyphormic association does not works:
from Pessoa where nome = 'Rafael';
Error: Unknown column 'pessoa1_1_.nome' in 'where clause'
Mapping:
<class name="Pessoa" table="bs_com_pessoa">
<id name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<joined-subclass name="PessoaFisica" table="bs_com_pessoa_fisica">
<key column="id_pessoa"/>
<property column="nome" name="nome" not-null="true"/>
</joined-subclass>
<joined-subclass name="PessoaJuridica" table="bs_com_pessoa_juridica">
<key column="id_pessoa"/>
<property name="razaoSocial" column="razao_social" not-null="true"/>
<property name="nomeFantasia" column="nome_fantasia" not-null="true"/>
</joined-subclass>
</class>
<class name="Cliente" table="bs_erp_cliente">
<id name="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<many-to-one name="pessoa" class="Pessoa" column="id_pessoa" not-null="true" unique="true" cascade="all"/>
</class>
SQL generated by Hibernate:
select cliente0_.id as id18_, cliente0_.id_pessoa as id2_18_ from bs_erp_cliente cliente0_, bs_com_pessoa pessoa1_ where cliente0_.id_pessoa=pessoa1_.id and (pessoa1_1_.nome like ?) order by pessoa1_1_.nome
There is not pessoa1_1_ in the from clause.
--
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, 11 months
[Hibernate-JIRA] Created: (HHH-5077) @OrderBy in combination with NamedQuery throws an error
by Thomas Götzinger (JIRA)
@OrderBy in combination with NamedQuery throws an error
-------------------------------------------------------
Key: HHH-5077
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5077
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Environment: 0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.5.0-Final
31 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.0-Final
47 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
47 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
63 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
360 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
375 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.5.0-Final
Oracle 10g
Reporter: Thomas Götzinger
Attachments: orderby_bug.zip
I have a OneToMany Relationship between ??ClientEntity?? and ??ChildEntity??. Both inherit from ??SuperEntity??.
{code:title=SuperEntity.java|borderStyle=solid}
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class SuperEntity
{
@Id
protected int id;
protected int position = 0;
{code}
Here is the Relationship-Definition of ClientEntity
{code:title=ClientEntity.java|borderStyle=solid}
public class ClientEntity
extends SuperEntity
{
public ClientEntity(int id)
{
this.id = id;
}
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_id")
@OrderBy("position")
List<ChildEntity> childs = new ArrayList<ChildEntity>();
{code}
The ??position??-Attribute (as well as the column) is located in the ??SuperEntity?? (Parent of ChildEntity), and should be used to order the entries of the list.
{code:title=OrderByWithInheritanceTEst.java|borderStyle=solid}
ClientEntity find = entityManager.find(ClientEntity.class, 1);
{code}
If I load the Entity with the find-Method or a NamedQuery the Exception beneath occurs:
Hibernate fills in the tablename of the SuperEntity after the alias of the tablename of the ChildEntity and in front of the columnname.
Hibernate indicates the wrong mapping at startup time of the SessionFactory. It prints out the following log:
{code}
orderByFragment(order-by)
> sortSpecification({sort specification})
> sortKeySpecification(sort key)
> sortKey($PlaceHolder$.SuperEntity.position)
{code}
*$PlaceHolder$.SuperEntity.position*
The SQL-Output of Hibernate-Log (see the last part of the statement) shows that the wrong pattern above is used to address the position-column.
{code}
Hibernate: select cliententi0_.id as id0_1_, cliententi0_1_.position as position0_1_, childs1_.parent_id as parent2_0_3_, childs1_.id as id3_, childs1_.id as id0_0_, childs1_1_.position as position0_0_ from ClientEntity cliententi0_ inner join SuperEntity cliententi0_1_ on cliententi0_.id=cliententi0_1_.id left outer join ChildEntity childs1_ on cliententi0_.id=childs1_.parent_id left outer join SuperEntity childs1_1_ on childs1_.id=childs1_1_.id where cliententi0_.id=? order by childs1_.SuperEntity.position asc
{code}
*childs1_.SuperEntity.position asc*
Beside the Wrong *SuperEntity*-Part the ??PlaceHolder?? has been replaced by the alias of the ChildEntity -table, whereas the alias of the SuperEntity-table would be the correct replacement.
{quote}
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not load an entity: [net.goetzingert.orderbytest.ClientEntity#1]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1179)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:575)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:529)
at net.goetzingert.orderbytest.OrderByWithInheritanceTEst.testFind(OrderByWithInheritanceTEst.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [net.goetzingert.orderbytest.ClientEntity#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1937)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:997)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:990)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:554)
... 26 more
Caused by: java.sql.SQLException: ORA-00904: "CHILDS1_"."SUPERENTITY"."POSITION": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1124)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1849)
at org.hibernate.loader.Loader.doQuery(Loader.java:718)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1933)
... 38 more
{quote}
--
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, 11 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
13 years, 11 months
[Hibernate-JIRA] Created: (ANN-807) @OrderBy don't quote identifiers
by StarBreeze (JIRA)
@OrderBy don't quote identifiers
--------------------------------
Key: ANN-807
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-807
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: Hibernate 3.3.1.GA, MS SQL Server 2000
Reporter: StarBreeze
@OrderBy annotation ignoring quote identifiers.
Test case.
1. Mapping class:
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
@Entity
@Table(name = "Category")
public class Category implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private Integer order;
private Category parent;
private List<Category> children;
@Id
@Column(name = "CategoryId")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "Name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "`Order`")
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
@ManyToOne()
@JoinColumn(name = "ParentCategoryId")
public Category getParent() {
return parent;
}
public void setParent(Category parent) {
this.parent = parent;
}
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", fetch = FetchType.EAGER)
@OrderBy("order")
public List<Category> getChildren() {
return children;
}
public void setChildren(List<Category> children) {
this.children = children;
}
}
2. Fetch code:
Criteria criteria = getSession().createCriteria(Category.class);
criteria.add(Restrictions.eq("name", "Indexes"));
Category category = (Category) criteria.uniqueResult();
Hibernate generates correct select part with wrong "order by":
select this_.CategoryId as CategoryId1_1_, this_.Name as Name1_1_, this_.[Order] as Order3_1_1_, this_.ParentCategoryId as ParentCa4_1_1_, children2_.ParentCategoryId as ParentCa4_3_, children2_.CategoryId as CategoryId3_, children2_.CategoryId as CategoryId1_0_, children2_.Name as Name1_0_, children2_.[Order] as Order3_1_0_, children2_.ParentCategoryId as ParentCa4_1_0_ from Category this_ left outer join Category children2_ on this_.CategoryId=children2_.ParentCategoryId where this_.Name=? order by Order asc
Result:
org.hibernate.exception.SQLGrammarException: could not execute query
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.loader.Loader.doList(Loader.java:2231)
org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2157)
org.hibernate.loader.Loader.list(Loader.java:2117)
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
caused by:
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'Order'.
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1458)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:388)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4016)
com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1414)
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:176)
com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:151)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:281)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
org.hibernate.loader.Loader.doQuery(Loader.java:697)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
org.hibernate.loader.Loader.doList(Loader.java:2228)
org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2157)
org.hibernate.loader.Loader.list(Loader.java:2117)
org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328)
--
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, 11 months
[Hibernate-JIRA] Created: (HHH-7231) @OrderBy fails if order by property is in inherited superclass
by Roberto Ruiz (JIRA)
@OrderBy fails if order by property is in inherited superclass
--------------------------------------------------------------
Key: HHH-7231
URL: https://hibernate.onjira.com/browse/HHH-7231
Project: Hibernate ORM
Issue Type: Bug
Components: entity-manager
Affects Versions: 4.1.1
Environment: Java 1.6
Windows XP SP3
Eclipse 3.6
Spring 3.1.1
MySQL (Same error in oracle and HSQLDB)
Reporter: Roberto Ruiz
I try to order a Set or List mapped by @ManyToOne using a property that is in the inherited superclass of the child side.
When I try to recover the Set, the query fails because generated SQL is wrong
Next I write a simplified example (getters an setter ommited):
@Entity
@Table(name="PLACE")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Place {
@Id
@Column(name="PLACE_ID")
private Long id;
@Column(name="PLACE_NAME")
private String name;
}
@Entity
@Table(name="LOCALITY")
@PrimaryKeyJoinColumn(name="PLACE_ID", referencedColumnName="PLACE_ID")
public class Locality extends Place {
@Column(name="LOCALITY_MAJOR")
private String major;
@OneToMany(mappedBy="locality")
@OrderBy("historyCount")
private Set<LocalityHistorical> history;
}
@Entity
@Table(name="PLACE_HIST")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class PlaceHistorical {
@Id
@Column(name="HIST_PLACE_ID")
private Long id;
@Column(name="HIST_PLACE_NAME")
private String name;
@Column(name="HIST_COUNT")
private Long historyCount;
}
@Entity
@Table(name="LOCALITY_HIST")
@PrimaryKeyJoinColumn(name="HIST_PLACE_ID", referencedColumnName="HIST_PLACE_ID")
public class LocalityHistorical extends PlaceHistorical {
@ManyToOne(optional=false)
@JoinColumn(name="PLACE_ID")
private Locality locality;
@Column(name="LOCALITY_MAJOR")
private String major;
}
As you may see in the example, the entity "Locality" has a Set called histiry of "LocalityHistorical". The set is ordered by historyCount which is a field of the superentity "PlaceHistorical".
The generated SQL is:
select
history0_.PLACE_ID as PLACE3_0_1_,
history0_.HIST_PLACE_ID as HIST2_1_,
history0_.HIST_PLACE_ID as HIST1_2_0_,
history0_1_.HIST_COUNT as HIST2_2_0_,
history0_1_.HIST_PLACE_NAME as HIST3_2_0_,
history0_.PLACE_ID as PLACE3_3_0_,
history0_.LOCALITY_MAJOR as LOCALITY1_3_0_
from
LOCALITY_HIST history0_
inner join
PLACE_HIST history0_1_
on history0_.HIST_PLACE_ID=history0_1_.HIST_PLACE_ID
where
history0_.PLACE_ID=?
order by
history0_.PLACE_HIST.HIST_COUNT asc
The error is in the order by clause which should be "history0_1_.HIST_COUNT" instead of "history0_.PLACE_HIST.HIST_COUNT"
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 11 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
13 years, 11 months