[Hibernate-JIRA] Created: (HHH-5117) HQL Query containing joins does not work
by Thierry Brunet (JIRA)
HQL Query containing joins does not work
----------------------------------------
Key: HHH-5117
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5117
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Environment: Eclipse
java.vendor=Sun Microsystems Inc., env.SESSION_MANAGER=local/tb-it-scape:@/tmp/.ICE-unix/2248,unix/tb-it-scape:/tmp/.ICE-unix/2248, localRepository=/home/thierry/.m2/repository, sun.java.launcher=SUN_STANDARD, hibernate.connection.url=jdbc:mysql://localhost:3306/IT_Scape, sun.management.compiler=HotSpot Client Compiler, os.name=Linux, persistence.pojo.xmlfilelist=src/test/resources/PojoList.xml, sun.boot.class.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/classes, env.PWD=/home/thierry, env.XDG_SESSION_COOKIE=b905806326f11e0b772623114a1c05da-1271232614.772432-144904942, sun.desktop=gnome, env.LANG=en_US.UTF-8, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.6.0_16-b01, env.DISPLAY=:0.0, hibernate.cache.provider_class=${hibernate.cache.provider_class}, user.name=thierry, env.USER=thierry, env.SHELL=/bin/bash, env.MOZILLA_FIVE_HOME=/usr/lib/xulrunner-addons, env.DESKTOP_SESSION=gnome, env.XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/, env.NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, env.PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games, user.language=en, sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386, classworlds.conf=/home/thierry/workspace/.metadata/.plugins/org.maven.ide.eclipse/launches/m2conf8195292387699736565.tmp, java.version=1.6.0_16, user.timezone=Europe/Paris, env.DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-K4MHiUhcae,guid=01640d0f119ca6a1030375b74bc57868, sun.arch.data.model=32, env.SSH_AGENT_PID=2293, java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/endorsed, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, file.encoding.pkg=sun.io, file.separator=/, java.specification.name=Java Platform API Specification, hibernate.format_sql=false, env.GDMSESSION=gnome, env.GNOME_DESKTOP_SESSION_ID=this-is-deprecated, java.class.version=50.0, env.GDM_KEYBOARD_LAYOUT=fr, persistence.pojo.view.creator=com.itscape.persistence.view.mysql.ViewCreatorImpl, env.GNOME_KEYRING_PID=2233, user.country=US, java.home=/usr/lib/jvm/java-6-sun-1.6.0.16/jre, java.vm.info=mixed mode, sharing, env.LOGNAME=thierry, os.version=2.6.31-20-generic, path.separator=:, java.vm.version=14.2-b01, hibernate.connection.password=passwd, java.awt.printerjob=sun.print.PSPrinterJob, sun.io.unicode.encoding=UnicodeLittle, hibernate.connection.username=itscape, env.GDM_LANG=en_US.UTF-8, user.home=/home/thierry, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=update, java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/../lib/i386:/usr/lib/xulrunner-addons:/usr/java/packages/lib/i386:/lib:/usr/lib, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLDialect, maven.home=/opt/apache-maven-2.2.1, java.runtime.name=Java(TM) SE Runtime Environment, java.class.path=/opt/apache-maven-2.2.1/boot/classworlds-1.1.jar, env.XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, m2eclipse.workspace.state=/home/thierry/workspace/.metadata/.plugins/org.maven.ide.eclipse/workspacestate.properties, env.GTK_RC_FILES=/etc/gtk/gtkrc:/home/thierry/.gtkrc-1.2-gnome2, sun.cpu.endian=little, sun.os.patch.level=unknown, env.HOME=/home/thierry, surefire.test.class.path=/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/persistence/data-persistence/target/test-classes:/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/persistence/data-persistence/target/classes:/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/persistence/model/target/model.jar:/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/model-serializer/target/model-serializer.jar:/home/thierry/.m2/repository/org/hibernate/hibernate-core/3.5.0-Final/hibernate-core-3.5.0-Final.jar:/home/thierry/.m2/repository/antlr/antlr/2.7.6/antlr-2.7.6.jar:/home/thierry/.m2/repository/commons-collections/commons-collections/3.1/commons-collections-3.1.jar:/home/thierry/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/thierry/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar:/home/thierry/.m2/repository/javax/transaction/jta/1.1/jta-1.1.jar:/home/thierry/.m2/repository/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar:/home/thierry/.m2/repository/org/hibernate/hibernate-annotations/3.5.0-Final/hibernate-annotations-3.5.0-Final.jar:/home/thierry/.m2/repository/org/hibernate/hibernate-commons-annotations/3.2.0.Final/hibernate-commons-annotations-3.2.0.Final.jar:/home/thierry/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.0.Final/hibernate-jpa-2.0-api-1.0.0.Final.jar:/home/thierry/.m2/repository/javassist/javassist/3.8.0.GA/javassist-3.8.0.GA.jar:/home/thierry/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar:/home/thierry/.m2/repository/org/json/json/20090211/json-20090211.jar:/home/thierry/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar:/home/thierry/.m2/repository/org/apache/felix/org.osgi.core/1.0.0/org.osgi.core-1.0.0.jar:/home/thierry/.m2/repository/org/slf4j/slf4j-log4j12/1.5.10/slf4j-log4j12-1.5.10.jar:/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/keystore/target/keystore.jar:/home/thierry/.m2/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar:/home/thierry/.m2/repository/org/testng/testng/5.10/testng-5.10-jdk15.jar:/home/thierry/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:/home/thierry/.m2/repository/org/osgi/osgi_R4_core/1.0/osgi_R4_core-1.0.jar:/home/thierry/.m2/repository/org/osgi/osgi_R4_compendium/1.0/osgi_R4_compendium-1.0.jar:, env.LD_LIBRARY_PATH=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/../lib/i386:/usr/lib/xulrunner-addons, java.io.tmpdir=/tmp, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, env.SSH_AUTH_SOCK=/tmp/keyring-D2aK63/socket.ssh, os.arch=i386, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.ext.dirs=/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/ext:/usr/java/packages/lib/ext, env.XAUTHORITY=/var/run/gdm/auth-for-thierry-4zaQj6/database, user.dir=/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/persistence/data-persistence, env.SPEECHD_PORT=7560, env.GTK_MODULES=canberra-gtk-module, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, basedir=/home/thierry/workspace/ITSCAPE/branch/IT-Scape_1_0/IT-Scape/modules/data/trunk/persistence/data-persistence, hibernate.cache.use_second_level_cache=false, env.ORBIT_SOCKETDIR=/tmp/orbit-thierry, env.USERNAME=thierry, env.GNOME_KEYRING_SOCKET=/tmp/keyring-D2aK63/socket, file.encoding=UTF-8, env.GPG_AGENT_INFO=/tmp/seahorse-YD55iC/S.gpg-agent:2316:1, java.specification.version=1.6, hibernate.connection.isolation=2, hibernate.connection.pool_size=10, hibernate.show_sql=false}
SLF4
Reporter: Thierry Brunet
Priority: Critical
I am working on upgrading of my application from Hibernate 3.3.2.GA to 3.5.0 Hibernate final release.
The HQL queries, which contain associations and joins like for instance
"select ds, mgtrela,element from DataSource join ds.management as mgtrela Join mgtrela.managedElement as element",
do not work.
I have got the following exception
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2297)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
at org.hibernate.loader.Loader.list(Loader.java:2167)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:448)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at com.itscape.persistence.event.PersistenceManagerEventTest.test1a_BulkInsert(PersistenceManagerEventTest.java:93)
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.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:609)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:532)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:686)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1018)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:128)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.runWorkers(TestRunner.java:759)
at org.testng.TestRunner.privateRun(TestRunner.java:592)
at org.testng.TestRunner.run(TestRunner.java:486)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:332)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:327)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:299)
at org.testng.SuiteRunner.run(SuiteRunner.java:204)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:912)
at org.testng.TestNG.runSuitesLocally(TestNG.java:876)
at org.testng.TestNG.run(TestNG.java:784)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
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.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997)
Caused by: java.sql.SQLException: Column 'OSCatalo1_7_2_' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1093)
at com.mysql.jdbc.ResultSetImpl.getLong(ResultSetImpl.java:2942)
at org.hibernate.type.LongType.get(LongType.java:51)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:184)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:173)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:105)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2267)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1423)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1351)
at org.hibernate.loader.Loader.getRow(Loader.java:1251)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:619)
at org.hibernate.loader.Loader.doQuery(Loader.java:745)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.doList(Loader.java:2294)
... 37 more
My model contains the annotation
@Entity
@Table(name = "core_element"
, uniqueConstraints= @UniqueConstraint(columnNames={ "EId"})
)
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Element implements Serializable{
..}
@Entity
@Table(name = "core_item")
@Inheritance(strategy = InheritanceType.JOINED)
abstract public class Item extends Element {
}
@MappedSuperclass
public abstract class System extends Item
public void setOSCatalogId(long OSCatalogId) {
this.OSCatalogId = OSCatalogId;
}
public long getOSCatalogId() {
return OSCatalogId;
}
}
Entity
@Table(name = "core_computersystem")
@Inheritance(strategy = InheritanceType.JOINED)
public class ComputerSystem extends System {
}
Remark, my application works correctly with hibernate 3.3.2 GA.
I must pass about 300 unit tests in front of hibernate 3.5.0 so that I can adopt it
--
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: (HV-292) Provide a constraint annotation @ScriptAssert
by Gunnar Morling (JIRA)
Provide a constraint annotation @ScriptAssert
---------------------------------------------
Key: HV-292
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-292
Project: Hibernate Validator
Issue Type: New Feature
Components: validators
Affects Versions: 4.1.0-Beta-1
Reporter: Gunnar Morling
Assignee: Hardy Ferentschik
Quite often the validation of one bean property depends on the value of another property of the same bean. In such case a custom class-level constraint and a corresponding validator have to be implemented.
This effort can be reduced by providing a generic class-level constraint, which allows to evaluate arbitrary script expressions based on the annotated class as in the following example:
@ScriptAssert(lang = "groovy", script = "_this.startDate.before(_this.endDate)")
public class CalendarEvent {
private Date startDate;
private Date endDate;
//...
}
The blog post http://musingsofaprogrammingaddict.blogspot.com/2009/08/script-annotation... describes, how such a constraint could be realized using the JSR 223 ("Scripting for the Java Platform") API.
In alternative to solely rely on JSR 223 it should be investigated, whether a more general approach could be taken to enable the integration of scripting/expression languages, for which no JSR 223 binding exists (e.g. Spring EL). This could be realized by providing a SPI mechanism, which allows to plug-in additional script engine providers.
--
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: (HV-302) JAXB shouldn't be required when not using XML configuration
by Gunnar Morling (JIRA)
JAXB shouldn't be required when not using XML configuration
-----------------------------------------------------------
Key: HV-302
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-302
Project: Hibernate Validator
Issue Type: Improvement
Components: engine
Affects Versions: 4.1.0.Beta1
Reporter: Gunnar Morling
Assignee: Hardy Ferentschik
Fix For: 4.1.0
By calling Configuration#ignoreXmlConfiguration() any XML config files (validation.xml, mapping XML files) are ignored by HV. Nevertheless JAXB is required on the class path, as in any case the class org.hibernate.validator.xml.XmlMappingParser (which imports javax.xml.bind.*) is loaded, also if no XML mapping files are to be processed.
XmlMappingParser should only be loaded, when at least one XML mapping exists. While this makes no difference when running on Java 6 (as JAXB is part of the Java runtime itself), this allows to use HV on Java 5 without adding JAXB (and its transitive dependencies) to the class path.
--
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-4891) Using certain column names which mirror SQL function names causes "ambiguous column" SQL errors
by Manuel Dominguez Sarmiento (JIRA)
Using certain column names which mirror SQL function names causes "ambiguous column" SQL errors
-----------------------------------------------------------------------------------------------
Key: HHH-4891
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4891
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2
Environment: Error verified with Oracle, MySQL and H2 database engines.
Reporter: Manuel Dominguez Sarmiento
We have some columns names "floor" and "hash". This used to work fine until 3.5.0 Beta 2. This and later releases fail when a query involves a join with two tables and both each contain a column named either "floor" or "hash" with an "ambiguous column" error.
3.5.0 Beta 1 and previous releases work fine. Something must have changed in Beta 2 that is causing some kind of recognition of SQL function names, but I can't seem to pinpoint any issue related to this in the changelong.
I'm pretty sure this would also happen with other column names such as "ceil", "abs", etc. which although they might be SQL function names they are not reserved keywords, and thus they are valid column names.
--
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-5114) Column 'timestamp' in field list is ambiguous
by ChB (JIRA)
Column 'timestamp' in field list is ambiguous
---------------------------------------------
Key: HHH-5114
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5114
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.0-Final
Environment: MySQL 5.1.45, MySQL5InnoDBDialect
Reporter: ChB
I ran into the following error today: 'Column 'timestamp' in field list is ambiguous'
So i tried to figure out what is causing this. I have the following mapping (
public class X
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "y")
@org.hibernate.annotations.Fetch(FetchMode.JOIN)
public Y getY() {
return this.y;
}
}
public class Y
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "x_id", unique = true, nullable = false, insertable = false, updatable = false)
public X getX() {
return this.x;
}
}
and had the following Query "select x from X as y ..." which resulted in
select
bla0_.x_id as x_id1_5_4_,
bla0_.xyz as xyz2_5_4_,
timestamp as timestamp5_4_,
foo1_.id as id3_0_,
...
bla4_.x_id as x_id1_5_3_,
bla4_.xyz as xyz2_5_3_,
timestamp as timestamp5_3_
from Y bla0_
left outer join X foo1_ on bla0_.x_id=foo1_.id
...
left outer join Y bla4_ on foo1_.id=bla4_.x_id
As you can obviously see this is a combination of 2 bugs:
1.) The text 'bla0_.' is missing prior to 'timestamp' (first occurence) and 'bla4_.' is missing prior to 'timestamp' (next occurence)
2.) For no reason the table Y is loaded twice from the DB (as bla0_ and bla4_)
This might be dialect specific, I'm using MySQL5InnoDBDialect.
I could work around this by removing "@org.hibernate.annotations.Fetch(FetchMode.JOIN)", but thats not a real solution. This did not happend with hibernate 3.3.
--
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-4541) collection_valued_input_parameter not working in IN statement
by Farrukh Najmi (JIRA)
collection_valued_input_parameter not working in IN statement
-------------------------------------------------------------
Key: HHH-4541
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4541
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0.Beta-1
Reporter: Farrukh Najmi
3.5.0-Beta1 of hibernate-entitymanager supports JPA 2.0.
According to section 4.6.9 of the JPA 2.0 spec an IN statement can have a collection_valued_input_parameter:
"
in_expression ::=
{state_field_path_expression | type_discriminator} [NOT] IN
{ ( in_item {, in_item}* ) | (subquery) | collection_valued_input_parameter }
in_item ::= literal | single_valued_input_parameter
"
When I try the following query:
SELECT DISTINCT Object(p) FROM org.freebxml.omar.jaxb.bindings.rim._4_0.PersonType p, org.freebxml.omar.jaxb.bindings.rim._4_0.AssociationType a WHERE a.sourceObject = :sourceObjectId AND p.id = a.targetObject AND a.type IN :typexxx
with a List<String> value for collection_valued_input_parameter :typexxx I get the following unexpected error:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: : near line 1, column 226 [SELECT DISTINCT Object(p) FROM org.freebxml.omar.jaxb.bindings.rim._4_0.PersonType p, org.freebxml.omar.jaxb.bindings.rim._4_0.AssociationType a WHERE a.sourceObject = :sourceObjectId AND p.id = a.targetObject AND a.type IN :typexxx ]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:284)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1585)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:121)
--
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-4922) Incorrect Parsing of IN-Clause in JPQL
by Pierce Wetter (JIRA)
Incorrect Parsing of IN-Clause in JPQL
--------------------------------------
Key: HHH-4922
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4922
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-Beta-4
Environment: 3.5.0-Beta-4, ALL
Reporter: Pierce Wetter
In the reference implementation, a query such as the following:
select u from User u where u.loginName IN :logins
will accept :logins as a parameter of Collection<String>. While:
select u from User u where u.loginName IN (:login1)
will accept :login1 as a String.
For a collection, Hibernate insists on:
select u from User u where u.loginName IN (:logins)
and it throws an error on:
select u from User u where u.loginName IN :logins
But not only does this not match the reference implementation, but it precludes the use of:
select u from User u where u.loginName IN (:login1. :login2, :login3)
That is, is prevents the use of the IN clause with a hard coded set of String values.
Test Case:
It's pretty trivial. Both of these should be allowed:
Query qTwoLogins = em.createQuery(
"select u from User u where ou.loginId in (:login1, :login2)"
);
Query qCollectionLogins = em.createQuery(
"select u from User u where u.login in :logins"
);
qTwoLogins.setParameter("login1","testuser1");
qTwoLogins.setParameter("login2","testuser2");
HashSet<String> list= new HashSet<String>(2);
list.add("testuser1");
list.add("testuser2");
qCollectionLogins.setParameter("logins",list);
--
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