[Hibernate-JIRA] Created: (HHH-5339) Restrictions.ilike doesn't work on integer columns
by Chris Wilson (JIRA)
Restrictions.ilike doesn't work on integer columns
--------------------------------------------------
Key: HHH-5339
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5339
Project: Hibernate Core
Issue Type: Bug
Reporter: Chris Wilson
Hibernate doesn't like using {@link Restrictions#ilike} on integer columns.
It uses the SQL lowercase function on the column, the result of which
must be a character type (CHAR or VARCHAR) because:
bq. LOWER Converts a string to all lowercase characters ([SQL in a Nutshell|http://oreilly.com/catalog/sqlnut/chapter/ch04.html])
But IlikeExpression.getTypedValues() asks the criteria query for the type of the typed values, which returns the underlying type, which in this case is an integer type.
Hibernate then throws a ClassCastException, trying to fit the string parameter into an Integer TypedValue:
* java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
* at org.hibernate.type.IntegerType.set(IntegerType.java:64)
* at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
* at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
* at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1732)
* at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1703)
* at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1593)
* at org.hibernate.loader.Loader.doQuery(Loader.java:696)
* at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
* at org.hibernate.loader.Loader.doList(Loader.java:2232)
* at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
* at org.hibernate.loader.Loader.list(Loader.java:2124)
* at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
* at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
* at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
* at org.wfp.rita.datafacade.RequestDao.listRequests(RequestDao.java:736)
I can't give you a patch because I can't build Hibernate because the actual instructions are missing from [http://www.hibernate.org/sourcecode.html]. I'll attach the test in a second.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-5341) "ambiguous column" SQL errors in Hibernate 3.5.3
by dnalos (JIRA)
"ambiguous column" SQL errors in Hibernate 3.5.3
------------------------------------------------
Key: HHH-5341
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5341
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.3
Environment: Java JDK 1.6.0_20
Hibernate Core 3.5.3
hibernate-jpa-2.0-api-1.0.0.Final.jar
mysql-connector-java-5.1.10-bin.jar
MySQL Database 5.1.37
Reporter: dnalos
Attachments: HibernateAmbiguousTest.zip
I had create a HHH-5086 for Hibernate 3.5.0 Final, but you close ist. The problem ist always in 3.5.3. I have create a Testcase for you, please test it. The Exception is as following:
============================================================
============================================================
============================================================
Hibernate: insert into item (_value, _version, _dbid) values (?, ?, ?)
Hibernate: insert into invoice (_item__dbID, _value, _version, _dbid) values (?, ?, ?, ?)
Hibernate: select invoice0_._dbid as column1_1_1_, _item__dbID as column4_1_1_, _value as column2_1_1_, _version as column3_1_1_, item1_._dbid as column1_0_0_, _value as column2_0_0_, _version as column3_0_0_ from invoice invoice0_ left outer join item item1_ on invoice0_._item__dbID=item1_._dbid where invoice0_._dbid=?
ERROR 11:01:48 0 Column '_value' in field list is ambiguous (JDBCExceptionReporter.java:101)
org.hibernate.exception.ConstraintViolationException: could not load an entity: [Invoice#201]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
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 HibernateAmbiguousTest.testAmbiguous(HibernateAmbiguousTest.java:53)
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.internal.runners.TestMethod.invoke(TestMethod.java:59)
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column '_value' in field list is ambiguous
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2077)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2228)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
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)
... 34 more
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4903) Ambiguous column in field list
by Luis Eduardo Villares Matta (JIRA)
Ambiguous column in field list
------------------------------
Key: HHH-4903
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4903
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Beta-4
Environment: O.S.: Linux 2.6.28-18-generic #59-Ubuntu SMP Thu Jan 28 01:40:19 UTC 2010 x86_64 GNU/Linux
Java.: Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
Web server: jetty-hightide-7.0.1.v20091125
DB Server: mysql Ver 14.14 Distrib 5.1.31, for debian-linux-gnu (x86_64) using EditLine wrapper
Reporter: Luis Eduardo Villares Matta
Priority: Blocker
When executing entityManager.find(ClassName.class, pk) caught the exception below.
Entities involved in the query below do not have any inheritance relationship (just composition), but they all contain a field named "private" (column name "_private")
Hibernate:
select
libraryite0_.id as id2_2_,
libraryite0_.active as active2_2_,
libraryite0_.createdDate as createdD3_2_2_,
libraryite0_.deleted as deleted2_2_,
libraryite0_.updatedDate as updatedD5_2_2_,
libraryite0_.defaultLocale as defaultL6_2_2_,
libraryite0_.name as name2_2_,
libraryite0_.parentId as parentId2_2_,
_private as column8_2_2_,
libraryite0_.typeId as typeId2_2_,
libraryite1_.id as id2_0_,
libraryite1_.active as active2_0_,
libraryite1_.createdDate as createdD3_2_0_,
libraryite1_.deleted as deleted2_0_,
libraryite1_.updatedDate as updatedD5_2_0_,
libraryite1_.defaultLocale as defaultL6_2_0_,
libraryite1_.name as name2_0_,
libraryite1_.parentId as parentId2_0_,
_private as column8_2_0_,
libraryite1_.typeId as typeId2_0_,
libraryite2_.id as id5_1_,
libraryite2_.active as active5_1_,
libraryite2_.createdDate as createdD3_5_1_,
libraryite2_.deleted as deleted5_1_,
libraryite2_.updatedDate as updatedD5_5_1_,
libraryite2_.folderish_ as folderish6_5_1_,
libraryite2_.libraryId as libraryId5_1_,
libraryite2_.name as name5_1_,
libraryite2_.xsd_ as xsd8_5_1_,
libraryite2_.xpaths_ as xpaths9_5_1_
from
TKBMLibraryItem libraryite0_
left outer join
TKBMLibraryItem libraryite1_
on libraryite0_.parentId=libraryite1_.id
left outer join
TKBMLibraryItemType libraryite2_
on libraryite1_.typeId=libraryite2_.id
where
libraryite0_.id=?
174363 [qtp1469937134-21] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 1052, SQLState: 23000
174363 [qtp1469937134-21] ERROR org.hibernate.util.JDBCExceptionReporter - Column '_private' in field list is ambiguous
174363 [qtp1469937134-21] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
org.hibernate.exception.ConstraintViolationException: could not load an entity: [com.totvs.kbm.model.LibraryItemModel#10128]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:95)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1916)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:65)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3212)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:437)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:418)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:223)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:126)
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:538)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:513)
at com.totvs.kbm.service.KnowledgeService.getLibraryItem(KnowledgeService.java:476)
at org.apache.jsp.html.kbm.rootitemsnavigation_jsp._jspService(org.apache.jsp.html.kbm.rootitemsnavigation_jsp:179)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
at com.totvs.kbm.core.web.RequestPipeline.doFilter(RequestPipeline.java:132)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:425)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:457)
at org.eclipse.jetty.server.session.SessionHandler.handle(SessionHandler.java:182)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:933)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
at org.eclipse.jetty.server.Server.handle(Server.java:334)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:992)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:541)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column '_private' in field list is ambiguous
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2077)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2228)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1827)
at org.hibernate.loader.Loader.doQuery(Loader.java:714)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:271)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1902)
... 45 more
2010-02-10 14:48:50.375:WARN::/html/kbm/rootitemsnavigation.jsp
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not load an entity: [com.totvs.kbm.model.LibraryItemModel#10128]
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1197)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:558)
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:513)
at com.totvs.kbm.service.KnowledgeService.getLibraryItem(KnowledgeService.java:476)
at org.apache.jsp.html.kbm.rootitemsnavigation_jsp._jspService(org.apache.jsp.html.kbm.rootitemsnavigation_jsp:179)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1216)
at com.totvs.kbm.core.web.RequestPipeline.doFilter(RequestPipeline.java:132)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:425)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:457)
at org.eclipse.jetty.server.session.SessionHandler.handle(SessionHandler.java:182)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:933)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
at org.eclipse.jetty.server.Server.handle(Server.java:334)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:992)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:541)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
at java.lang.Thread.run(Thread.java:619)
--
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, 6 months
[Hibernate-JIRA] Created: (HCANN-27) Audited class with @EmbeddedId and @ManyToOne relationship
by Rino Heinen (JIRA)
Audited class with @EmbeddedId and @ManyToOne relationship
----------------------------------------------------------
Key: HCANN-27
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-27
Project: Hibernate Commons Annotations
Issue Type: Bug
Affects Versions: 3.2.0
Environment: Hibernate Version: 3.5.3
DataBase: MySQL 5.1.37
Driver JDBC version: 5.1.12
Reporter: Rino Heinen
Hi,
there is a problem when a class is @Audited and this has an @EmbeddedId (only when the Embeddable class has ManyToOne relationship).
Example code:
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="TestAuditPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:mysql://192.168.0.6:3306/idm"/>
<property name="hibernate.ejb.event.post-insert"
value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-update"
value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-delete"
value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.pre-collection-update"
value="org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.pre-collection-remove"
value="org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-collection-recreate"
value="org.hibernate.envers.event.AuditEventListener" />
</properties>
</persistence-unit>
</persistence>
Class A:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testaudit;
import java.io.Serializable;
import javax.persistence.*;
import org.hibernate.envers.Audited;
/**
*
* @author heir
*/
@Entity
@Table(name="tblA")
@Audited
public class A implements Serializable {
@Id
private String name;
@OneToMany(mappedBy="bpk.a")
private java.util.List<B> bs;
public A()
{
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the bs
*/
public java.util.List<B> getBs() {
return bs;
}
/**
* @param bs the bs to set
*/
public void setBs(java.util.List<B> bs) {
this.bs = bs;
}
}
Class B:
@Entity
@Table(name="tblB")
@Audited
public class B implements Serializable {
@Id
private BPK bpk;
public B()
{
}
/**
* @return the bpk
*/
public BPK getBpk() {
return bpk;
}
/**
* @param bpk the bpk to set
*/
public void setBpk(BPK bpk) {
this.bpk = bpk;
}
}
Class BPK:
@Embeddable
public class BPK implements Serializable {
private String name;
@ManyToOne(targetEntity=testaudit.A.class,
cascade={CascadeType.ALL})
@JoinColumn(name="strAName")
private A a;
public BPK()
{
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the a
*/
public A getA() {
return a;
}
/**
* @param a the a to set
*/
public void setA(A a) {
this.a = a;
}
}
Exception:
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: TestAuditPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at testaudit.Main.main(Main.java:23)
Caused by: org.hibernate.HibernateException: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1396)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:891)
... 4 more
Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.ManyToOneType
at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addIdProperties(IdMetadataGenerator.java:75)
at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addId(IdMetadataGenerator.java:120)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:374)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:100)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:334)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 8 more
Java Result: 1
Thanks
Heinen Rino
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-5344) Hibernate reading propertyName instead of column_name
by Charles Sagayaraj (JIRA)
Hibernate reading propertyName instead of column_name
-----------------------------------------------------
Key: HHH-5344
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5344
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2 Final and Oracle 10g
Reporter: Charles Sagayaraj
Hi, I have been using the following in Telephone embeddable domain object.
@Column(name = "telephone_number")
private String telephoneNumber;
This was working fine when I used 3.3.2 version. After I have upgraded to 3.5.2 Final the hibernate API was using telephoneNumber to look for the column name in the Oracle table, and it started failing with "DB column doesn't exist" error.
I had to use @AttributeOverrides along with the @embedded to overcome this issue. Now my modified code looks like
@Embedded
@AttributeOverrides( {
@AttributeOverride(name= "telephoneNumber", column= @Column( name = "telephone_number"))
})
private Telephone tnInfo;
I am not sure why suddenly my original code was broken with Hibernate 3.5.2 Final upgrade. I would appreciate if someone can look into this issue and provide the fix in the earliest next hibernate release.
Thank you
Charles
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4624) QueryImpl.list() closes connection
by Dieter Freismuth (JIRA)
QueryImpl.list() closes connection
----------------------------------
Key: HHH-4624
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4624
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Environment: linux,
postgres 8.3 (same on oracle 11g, mssql 2005 and mysql)
Reporter: Dieter Freismuth
Priority: Critical
if an outer query.iterate() calls within an iteration step a query.list() the connection is closed and the next outer iteration step causes:
org.hibernate.exception.JDBCConnectionException: could not get next iterator result
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.impl.IteratorImpl.next(IteratorImpl.java:156)
the exception is only thrown if there is no transaction!
(works fine if done within an transaction)
call hierarchy:
QueryImpl.list()
-> SessionImpl.list(String query, QueryParameters queryParameters)
-> afterOperation(success); // within finally block
-> JDBCContext.afterNontransactionalQuery( success )
-> ConnectionManager.afterTransaction()
-> ConnectionManager.aggressiveRelease() // within if ( isAfterTransactionRelease() ) {
-> ConnectionManager.closeConnection()
--
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, 6 months