[Hibernate-JIRA] Created: (HV-13) Bug on the Oracle dialect : empty String is authorized whereas the field is declared as not-null.
by Fabien PERIE (JIRA)
Bug on the Oracle dialect : empty String is authorized whereas the field is declared as not-null.
-------------------------------------------------------------------------------------------------
Key: HV-13
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-13
Project: Hibernate Validator
Issue Type: Bug
Environment: Hibernate version :3.1.2
Hibernate dialect : org.hibernate.dialect.OracleDialect
Database : Oracle 10g
Reporter: Fabien PERIE
Priority: Minor
Hello,
The purpose of this example is to show a bug with the Oracle dialect.
I use Hibernate 3.1.2 !
I define a POJO in a mapping file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="fr.modele">
<class name="Person" table="PERS">
<!-- Identifiant de la personne -->
<id name="idPerson" type="string" unsaved-value="null">
<column name="PERS_IDEN" sql-type="char(12)" not-null="true"/>
<generator class="sequence">
<param name="sequence">pers.pers_seq_iden</param>
</generator>
</id>
<property name="name" column="PERS_NAME" not-null="true" />
<property name="firstName" column="PERS_FIRSTNAME"/>
</class>
</hibernate-mapping>
Detail Person Java object :
import fr.modele;
import java.io.Serializable;
public class Person implements Serializable {
private String idPerson;
private String name;
private String firstName;
/**
* Constructeur par défaut.
*/
public Person() {
}
public Serializable getId() {
return idPerson;
}
public void setId(Serializable id) {
this.idPerson = (String)id;
}
public String getIdPerson() {
return idPerson;
}
public void setIdPerson(String idPerson) {
this.idPerson = idPerson;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
If I try to save an objet which contains the following informations :
* idPerson : 1
* name : null
* nickName : Jim
Hibernate 3 logically returns the error : «
fr.org.springframework.orm.hibernate3.HibernateSystemException: not-null property references a null or
transient value: fr.modele.Person.name; nested exception is org.hibernate.PropertyValueException:
not-null property references a null or transient value: fr.modele.Person.name ».
But, if I persist an object which has an empty String instead of null value in the name attribute,
Hibernate 3 does not return an error. (!!!)
I think that the problem comes of the Oracle dialect object because Oracle does not make the difference between
an empty String and a null value.
Thanks,
Fabien PERIE.
--
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
17 years, 8 months
[Hibernate-JIRA] Commented: (HHH-1483) MySQL5: No Dialect mapping for JDBC type: -1
by David (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483?page=c... ]
David commented on HHH-1483:
----------------------------
I had this issue when running a native query. The dialect I was using was MySQLInnoDBDialect.. It had an issue with a 'text' column. I subclassed MySQLInnoDBDialect and did this
registerColumnType(Types.LONGVARCHAR, 65535, "text");
After debugging for a while I found it was actually getting the issue when going into getHibernateTypeName, not getTypeName. Ths register method above affects getTypeName, not getHibernateTypeName. Because of this I instead wrote
registerHibernateType(Types.LONGVARCHAR, 65535, "text");
This took care of my problem. Being the first time I have ever looked at Hibernate's source I have no idea if this is what I should be doing. Looking further I believe the fix to this issue (AGAIN 1st time looking at source) is to add the following to the constructor of org.hibernate.dialect./Dialect (Note I didn't test this approach but looking at the code it should surely fix the problem)
registerHibernateType( Types.LONGVARCHAR, Hibernate.STRING.getName() ); // TODO: Check make sure the 2nd arg is right
I am not sure if the second argument is what it should be -- I really have no idea what the difference between hibernateTypeNames and typeNames is suppose to be but I hope this helps someone fix this issue.
In my opinion this is a large bug and should be high priority since "text" is a very commonly used type and used by default when hibernate creates tables for you.
> MySQL5: No Dialect mapping for JDBC type: -1
> --------------------------------------------
>
> Key: HHH-1483
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1483
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2
> Environment: MySQL 5.0.18-nt
> Reporter: Sergey Vladimirov
> Priority: Minor
>
> MySQL5: No Dialect mapping for JDBC type: -1
> SELECT answpos,answer FROM votes_answers WHERE question=? ORDER BY answpos
> mysql> describe votes_answers;
> +----------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +----------+---------+------+-----+---------+-------+
> | question | int(11) | NO | MUL | | |
> | answpos | int(11) | NO | | | |
> | answer | text | YES | | NULL | |
> +----------+---------+------+-----+---------+-------+
> mysql> describe temp;
> +---------+---------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +---------+---------+------+-----+---------+-------+
> | answpos | int(11) | NO | | 0 | |
> | answer | text | YES | | NULL | |
> +---------+---------+------+-----+---------+-------+
> Please, let me know what to add to MySQL5Dialect :)
> Will it be ok to add? :
> registerColumnType( Types.LONGVARCHAR, "text" );
--
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
17 years, 8 months
[Hibernate-JIRA] Commented: (EJB-192) Serialization exception with hashCode() and eager-eager
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-192?page=co... ]
Emmanuel Bernard commented on EJB-192:
--------------------------------------
I am contemplating closing this one since it's a Sun's JVM bug.
> Serialization exception with hashCode() and eager-eager
> -------------------------------------------------------
>
> Key: EJB-192
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-192
> Project: Hibernate Entity Manager
> Issue Type: Bug
> Components: EntityManager
> Affects Versions: 3.2.0.cr1
> Environment: JBoss 4.0.4.GA-patch1 and SUN JDK 1.5.0_07 on Windows XP
> Reporter: Stefan Norberg
> Attachments: eager-eager.jar
>
>
> I have a problem with some weird stuff going on when I implement the equals()/hashCode() methods in my entites. The short version is that I get a NullPointerException on deserialization on the client side after a remote server request when I am using eager fetching in both Team and Player. If I set the player-> team to lazy it works.
> More details are on the Hibernate forum:
> http://forum.hibernate.org/viewtopic.php?p=2308640#2308640
> I'm going to post the test case here tomorrow when I get the code from work.
> All the fields in the entity are null when the the object hits the deserialization code and hence the exception... But the name is of course initialized when shown in my test case app later. What gives? Seems to me the deserialization is broken. Perhaps this is a bug in JBoss remoting, but since I can only get this with the Entity Manager I posted here.
> This workaround works fine I think, but something seems terribly broken in either Hibernate or Jboss (remoting?).
> public boolean equals(Object obj) {
> if (name == null) return super.equals(obj);
> if (obj instanceof Team) {
> Team other = (Team) obj;
> return other.getName().equals(this.getName());
> }
> return false;
> }
> public int hashCode() {
> if (name == null) return super.hashCode(obj);
> return name.hashCode();
> }
> Full stack trace of any exception that occurs:
> javax.ejb.EJBException: java.lang.NullPointerException
> at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
> at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
> at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
> at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
> at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
> at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
> at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
> at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
> at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
> at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
> Caused by: java.lang.NullPointerException
> at com.weirdstuff.Player.hashCode(Player.java:83)
> at java.util.HashMap.hash(HashMap.java:264)
> at java.util.HashMap.put(HashMap.java:382)
> at java.util.HashSet.add(HashSet.java:194)
> at java.util.AbstractCollection.addAll(AbstractCollection.java:318)
> at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:273)
> at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:183)
> at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
> at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
> at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
> at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
> at org.hibernate.loader.Loader.doQuery(Loader.java:717)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
> at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
> at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
> at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2821)
> at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:370)
> at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:351)
> at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:122)
> at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:178)
> at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:86)
> at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:871)
> at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:839)
> at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
> at org.hibernate.type.EntityType.resolve(EntityType.java:303)
> at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
> at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
> at org.hibernate.loader.Loader.doQuery(Loader.java:717)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
> at org.hibernate.loader.Loader.doList(Loader.java:2145)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:392)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:333)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:53)
> at com.weirdstuff.FacadeBean.getPlayers(FacadeBean.java:17)
> 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:585)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
> at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
> at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
> at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
> at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
> at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
> at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
> at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
> at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
> at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
> at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
> at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
> at org.jboss.remoting.Client.invoke(Client.java:525)
> at org.jboss.remoting.Client.invoke(Client.java:488)
> at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
> at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
> at $Proxy0.getPlayers(Unknown Source)
> at com.weirdstuff.TestHashCodeClient.testGetPlayer(TestHashCodeClient.java:51)
> 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:585)
> at junit.framework.TestCase.runTest(TestCase.java:154)
> at junit.framework.TestCase.runBare(TestCase.java:127)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
--
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
17 years, 8 months
[Hibernate-JIRA] Commented: (ANN-150) Consider higher level validations, such as email, URL, credit card, etc.
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-150?page=co... ]
Emmanuel Bernard commented on ANN-150:
--------------------------------------
Definitely URL is needed
> Consider higher level validations, such as email, URL, credit card, etc.
> ------------------------------------------------------------------------
>
> Key: ANN-150
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-150
> Project: Hibernate Annotations
> Issue Type: New Feature
> Components: validator
> Affects Versions: 3.1beta6
> Reporter: Ted Bergeron
> Priority: Minor
>
> I was looking at the release notes for commons validator 1.2 http://wiki.apache.org/jakarta-commons/ValidatorVersion120 and wondered if the higher level constructs fit the design goals of hibernate validator.
> They have email, URL, Credit card and ISBN. These could all be handled via @Pattern with regex matching a constant declared somewhere.
> Would it be desirable to have Hibernate supply the values for these constants? Such as:
> @Pattern(type="email") or @Pattern(regex=org.hibernate.validator.Pattern.EMAIL) or @Email
> Email and URL are global patterns. This probably wouldn't work for something like phone number which is locale sensitive.
--
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
17 years, 8 months
[Hibernate-JIRA] Created: (HHH-2569) Improve cast() HQL function to support user defined function calls
by Gergely Papp (JIRA)
Improve cast() HQL function to support user defined function calls
------------------------------------------------------------------
Key: HHH-2569
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2569
Project: Hibernate3
Issue Type: Improvement
Components: query-hql
Affects Versions: 3.2.3
Environment: Hibernate 3.2.3ga
DB2 UDB 8.1-9.0
Reporter: Gergely Papp
Attachments: CastFunction.java
The cast() function could enable the HQL language to call user defined functions that are not explicitly defined in the dialect.
This is quite easy, considering everything is ready for it in the Hibernate framework, except for the problems in the actual SQL rendering of the function.
Currently the org.hibernate.dialect.function.CastFunction's render() method receives the arguments as a list, where the last argument is always the target type of the cast. For functions undefined in the dialect the arguments are split at commas.
eg. cast (func(a,b) as int) is received as ["func(a", "b)", "int"]
The problem here is that the arguments are checked if their size equals to two. This is the case for pre-defined functions, but not for user functions that have more than 1 parameters. (NB. currently this allows you to call user-defined functions with a single parameter and only fails on multi parameter functions, which could classify this as a bug)
However if the method is modified, to accept arguments lists with more than 2 elements, and we concatenate the arguments before it, this issue could be solved.
This would enhance the HQL a lot, as using user defined functions in several projects is a must, but writing a new dialect for it is not something an average programmer can figure out.
The proposed modification is attached, it has been tested with DB2 and seems to work as expected, I hope it can find it's way in the release soon as our project depends on this.
(The best would be to connect to the db and query the user-defined functions from it on startup, and register those in the dialect, but I think that's quite a huge modification.)
--
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
17 years, 8 months
[Hibernate-JIRA] Created: (HHH-2565) HQL: elements() requires an alias to work?
by tenwit (JIRA)
HQL: elements() requires an alias to work?
------------------------------------------
Key: HHH-2565
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2565
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.0.5
Environment: Hibernate 3.0.5 (sorry, I can't check to see if the bug is still in any later version)
Reporter: tenwit
Priority: Minor
I'm using a simple named query to search for all objects that have a given value-element in a set. It works if I alias the object, but not if I don't. In the code below, query OrganisationsByType1 produces the given exception, OrganisationsByType2 works perfectly.
Mapping documents:<pre>
<class name="OrganisationImpl" table="Organisation">
...
<set name="Types" table="OrganisationTypeLink" lazy="true" cascade="all">
<key column="OrganisationID"/>
<element column="OrganisationTypeID" not-null="true"
type="OrganisationType"/>
</set>
</class>
<query name="OrganisationsByType1">
from OrganisationImpl
where :Type in elements(Types)
</query>
<query name="OrganisationsByType2">
from OrganisationImpl o
where :Type in elements(o.Types)
</query>
</pre>
Full stack trace of any exception that occurs:
<pre>java.lang.NullPointerException
at org.hibernate.hql.ast.MethodNode.handleElements(MethodNode.java:154)
at org.hibernate.hql.ast.MethodNode.resolveCollectionProperty(MethodNode.java:105)
at org.hibernate.hql.ast.CollectionFunction.resolve(CollectionFunction.java:22)
at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:538)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunction(HqlSqlBaseWalker.java:2273)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:3937)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:3854)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3517)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1333)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:388)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
</pre>...
--
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
17 years, 8 months