[
https://hibernate.onjira.com/browse/HHH-7046?page=com.atlassian.jira.plug...
]
Steve Ebersole edited comment on HHH-7046 at 2/9/12 10:23 AM:
--------------------------------------------------------------
{code:borderStyle=solid}
<class name="Principal" table="GK_PRINCIPAL" lazy="true"
abstract="true">
<id name="myPrimaryKey" column="GK_PKEY" access="field"
type="long">
<generator class="native">
<param name="sequence">gk_principal_gk_pkey_seq</param>
<param name="table">GK_SYSTEM</param>
<param name="column">GK_ID</param>
<param name="max_lo">100</param>
</generator>
</id>
<natural-id mutable="false" >
<property name="myUID" column="GK_UID" access="field"
type="uid" length="36" unique-key="uid"
not-null="true" />
</natural-id>
...
</class>
<joined-subclass name="User" extend="Principal"
table="GK_USER" lazy="true">
<key column="GK_PKEY"/>
....
</joined-subclass>
{code}
{noformat:borderStyle=solid}
Caused by: org.hibernate.exception.SQLGrammarException: FEHLER: Spalte user_.gk_uid
existiert nicht
Position: 122
at
org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy9.executeQuery(Unknown Source)
at
org.hibernate.persister.entity.AbstractEntityPersister.loadEntityIdByNaturalId(AbstractEntityPersister.java:4542)
at
org.hibernate.event.internal.DefaultResolveNaturalIdEventListener.loadFromDatasource(DefaultResolveNaturalIdEventListener.java:127)
at
org.hibernate.event.internal.DefaultResolveNaturalIdEventListener.resolveNaturalId(DefaultResolveNaturalIdEventListener.java:94)
at
org.hibernate.event.internal.DefaultResolveNaturalIdEventListener.onResolveNaturalId(DefaultResolveNaturalIdEventListener.java:60)
at org.hibernate.internal.SessionImpl.fireResolveNaturalId(SessionImpl.java:1000)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:170)
at
org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.resolveNaturalId(SessionImpl.java:2392)
at
org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.load(SessionImpl.java:2415)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1504)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396)
at de.usu.gatekeeper.server.objects.UserManager.getPrincipal(UserManager.java:689)
at de.usu.gatekeeper.server.objects.UserManager.getPrincipal(UserManager.java:671)
at de.usu.gatekeeper.server.session.ServerSession.getUser(ServerSession.java:280)
at
de.usu.gatekeeper.server.session.SessionManager.getHistoryEntry(SessionManager.java:1062)
at
de.usu.gatekeeper.server.session.SessionManager.createSession(SessionManager.java:468)
at de.usu.gatekeeper.server.provider.LoginServices$1.run(LoginServices.java:571)
at de.usu.gatekeeper.server.provider.LoginServices$1.run(LoginServices.java:1)
at
de.usu.gatekeeper.server.util.SecureContext.runWithSecurityManager(SecureContext.java:308)
... 39 more
Caused by: org.postgresql.util.PSQLException: FEHLER: Spalte user_.gk_uid existiert nicht
Position: 122
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
at
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 60 more
{noformat}
was (Author: ekupcik):
{code:borderStyle=solid}}
<class name="Principal" table="GK_PRINCIPAL" lazy="true"
abstract="true">
<id name="myPrimaryKey" column="GK_PKEY" access="field"
type="long">
<generator class="native">
<param name="sequence">gk_principal_gk_pkey_seq</param>
<param name="table">GK_SYSTEM</param>
<param name="column">GK_ID</param>
<param name="max_lo">100</param>
</generator>
</id>
<natural-id mutable="false" >
<property name="myUID" column="GK_UID" access="field"
type="uid" length="36" unique-key="uid"
not-null="true" />
</natural-id>
...
</class>
<joined-subclass name="User" extends="Principal"
table="GK_USER" lazy="true">
<key column="GK_PKEY"/>
....
</joined-subclass>
{{code}}
{{noformat}}
Caused by: org.hibernate.exception.SQLGrammarException: FEHLER: Spalte user_.gk_uid
existiert nicht
Position: 122
at
org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
at
org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy9.executeQuery(Unknown Source)
at
org.hibernate.persister.entity.AbstractEntityPersister.loadEntityIdByNaturalId(AbstractEntityPersister.java:4542)
at
org.hibernate.event.internal.DefaultResolveNaturalIdEventListener.loadFromDatasource(DefaultResolveNaturalIdEventListener.java:127)
at
org.hibernate.event.internal.DefaultResolveNaturalIdEventListener.resolveNaturalId(DefaultResolveNaturalIdEventListener.java:94)
at
org.hibernate.event.internal.DefaultResolveNaturalIdEventListener.onResolveNaturalId(DefaultResolveNaturalIdEventListener.java:60)
at org.hibernate.internal.SessionImpl.fireResolveNaturalId(SessionImpl.java:1000)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:170)
at
org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.resolveNaturalId(SessionImpl.java:2392)
at
org.hibernate.internal.SessionImpl$NaturalIdLoadAccessImpl.load(SessionImpl.java:2415)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1504)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
at org.hibernate.internal.CriteriaImpl.uniqueResult(CriteriaImpl.java:396)
at de.usu.gatekeeper.server.objects.UserManager.getPrincipal(UserManager.java:689)
at de.usu.gatekeeper.server.objects.UserManager.getPrincipal(UserManager.java:671)
at de.usu.gatekeeper.server.session.ServerSession.getUser(ServerSession.java:280)
at
de.usu.gatekeeper.server.session.SessionManager.getHistoryEntry(SessionManager.java:1062)
at
de.usu.gatekeeper.server.session.SessionManager.createSession(SessionManager.java:468)
at de.usu.gatekeeper.server.provider.LoginServices$1.run(LoginServices.java:571)
at de.usu.gatekeeper.server.provider.LoginServices$1.run(LoginServices.java:1)
at
de.usu.gatekeeper.server.util.SecureContext.runWithSecurityManager(SecureContext.java:308)
... 39 more
Caused by: org.postgresql.util.PSQLException: FEHLER: Spalte user_.gk_uid existiert nicht
Position: 122
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
at
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 60 more
{{noformat}}
Polymorphic query by natural ID broken
--------------------------------------
Key: HHH-7046
URL:
https://hibernate.onjira.com/browse/HHH-7046
Project: Hibernate ORM
Issue Type: Bug
Affects Versions: 4.1.0
Environment: Hibernate 4.1.0
Reporter: Emanuel Kupcik
I have a simple class hierarchy that is mapped as joined subclass
class Principal
{
String uid;
}
class User extends Princpal
{
}
class Group extends Princpal
{
}
Till 4.0 it was possible to retrieve a user the natural ID using a criteria query for
User.class and using uid as natural ID. In 4.1 this fails because Hibernate complains that
column user_.uid doesn't exist. I can can still retrieve the user by using a criteria
query for Principal.class.
So this works
Criteria loCriteria = loSession.createCriteria(Principal.class);
loCriteria.add(Restrictions.naturalId().set("uid", aUID));
and this no longer works
Criteria loCriteria = loSession.createCriteria(User.class);
loCriteria.add(Restrictions.naturalId().set("uid", aUID));
Hibernate knows the correct name of the column from the mapping file but in the end it
looks for it in the wrong table
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira