[Hibernate-JIRA] Commented: (HHH-1836) .class parameter in HQL query not converted into discriminator value properly
by Stian Lindhom (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1836?page=c... ]
Stian Lindhom commented on HHH-1836:
------------------------------------
This is also a problem when using named parameters, ie:
"from Item i where i.class = com.Item" will work
"from Item i where i.class = :clazz" and .setParameter("clazz", "com.Item") or .setParameter("clazz", Item.class) will not work (it will try to cast the String or Class to an Integer).
Hibernate 3.2.1.ga
> .class parameter in HQL query not converted into discriminator value properly
> -----------------------------------------------------------------------------
>
> Key: HHH-1836
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1836
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.0.5
> Environment: Win XP SP2, Hibernate 3.0.5, Sun Java 1.5.0_06
> Reporter: Ignat Zapolsky
>
> Hello!
> I have following problem:
> when using HQL query
> "select item.id, item.name from Item as item where item.class = ?"
> and trying to use clause Query.setParameter (0, SubItem.class)
> I am getting following exception from underlying database since hibernate doese not properly convert parameter into associated discriminator value:
> 2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000>
> 2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000>
> 2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item">
> 2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item">
> org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select abstractco0_.id as col_0_0_, abstractco0_.name as col_1_0_ from TABLE abstractco0_ where abstractco0_.type=?]; SQL state [37000]; error code [-16]; Wrong data type: For input string: "Item"; nested exception is java.sql.SQLException: Wrong data type: For input string: "Item
> java.sql.SQLException: Wrong data type: For input string: "Item"
> at org.hsqldb.jdbc.Util.throwError(Unknown Source)
> at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source)
> at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source)
> at org.hibernate.type.StringType.set(StringType.java:24)
> at org.hibernate.type.ClassType.set(ClassType.java:35)
> at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
> at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44)
> at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1115)
> at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1177)
> at org.hibernate.loader.Loader.doQuery(Loader.java:390)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
> at org.hibernate.loader.Loader.doList(Loader.java:1593)
> at org.hibernate.loader.Loader.list(Loader.java:1577)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
> Please also examine bug http://opensource.atlassian.com/projects/hibernate/browse/HHH-1749 it observes situation from discriminatort to class point of view.
> PS. There are several forum posts regarding almost same issues:
> http://forum.hibernate.org/viewtopic.php?t=956408&highlight=discriminator...
> http://forum.hibernate.org/viewtopic.php?t=941125&highlight=discriminator...
> PPS. If required I could provide sample mappings and code snippets.
--
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
18 years, 2 months
[Hibernate-JIRA] Assigned: (HHH-142) Property with Duplicated name
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-142?page=co... ]
Diego Pires Plentz reassigned HHH-142:
--------------------------------------
Assignee: Diego Pires Plentz
> Property with Duplicated name
> -----------------------------
>
> Key: HHH-142
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-142
> Project: Hibernate3
> Issue Type: Improvement
> Components: metamodel
> Affects Versions: 3.0 beta 4, 3.1 rc3
> Environment: WinXP, Hibernate 3 from CVS (2005.02.19) J2SE 5.0
> Reporter: Konstantin Sharenkov
> Assignee: Diego Pires Plentz
> Priority: Minor
> Fix For: 3.0 rc 1
>
>
> When I tryed to Implement Parametrized user type to support
> Native J2SE 5.0 Enums as VARCHAR.
> I randomply detect that I able to set 2 properties with the same name at one class.
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping
> PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <hibernate-mapping package="com.enterra.tth.po" >
> <typedef class="com.enterra.tth.po.NativeEnumType" name="ActorAttributeType">
> <param name="enumClass">com.enterra.tth.po.ActorAttribute$Type</param>
> </typedef>
>
> <class name="ActorAttribute" table="t_actor_attribute" optimistic-lock="version" >
> <cache usage="read-write"/>
> <!-- Standrt part of mapping -->
> <id name="id" type="string" >
> <column name="f_id" sql-type="char(32)" not-null="true"/>
> <generator class="uuid.hex"/>
> </id>
>
> ...
> <property name="type" type="ActorAttributeType">
> <column name="f_type" sql-type="varchar"/>
> </property>
> <property name="type" type="string">
> <column name="f_value" sql-type="varchar"/>
> </property>
> </class>
> </hibernate-mapping>
> See property "type".
> Aclually getter and setter use com.enterra.tth.po.ActorAttribute$Type
> But both in background will use VARCHAR.
> As result I recieved class cast exception com.enterra.tth.po.ActorAttribute$Type to String.
> I think it will be better to disable duplicated properties.
> Or generate warning may be.
> Thanks.
> PS.
> After I update Hibernate 3 from cvs today and rebuild it
> I have started to recieve following exception.
> java.lang.NullPointerException
> at org.hibernate.tuple.PojoTuplizer.handleProperty(PojoTuplizer.java:82)
> at org.hibernate.tuple.AbstractTuplizer.<init>(AbstractTuplizer.java:77)
> at org.hibernate.tuple.PojoTuplizer.<init>(PojoTuplizer.java:53)
> at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:45)
> at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:202)
> at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:398)
> at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
> at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
> at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:198)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
> Hope it will help you too.
--
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
18 years, 2 months
[Hibernate-JIRA] Commented: (HHH-544) select new ... results in n+1 selects
by Dan Allen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-544?page=co... ]
Dan Allen commented on HHH-544:
-------------------------------
Would it be reasonable to request some way to add a hint that forces an eager load?
As a particular use case, I needed to query for a set of associated entities and their frequency within a table.
select q, count(*) from Queue q group by q
So to make things pretty and object oriented, I made a QueueFrequency object
select new QueueFrequency(q, count(*)) from Queue q group by q
The result set List<QueueFrequency> is then passed on to some other area of the code and does calculations on those queues and their frequencies. As soon as that code touches the queue in one of the QueueFrequency instances, it triggers a select (eventually leading to n+1)
As a workaround, I just ran the first query, and then iterated over its results to generate the QueueFrequency objects, and then returned the List<QueueFrequency> result. It just seems lame not to be able to push this work into the session manager.
> select new ... results in n+1 selects
> -------------------------------------
>
> Key: HHH-544
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-544
> Project: Hibernate3
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.0.5
> Environment: Hibernate 3.0.5, Oracle 8i, JDK 1.4.2
> Reporter: Salvatore Insalaco
> Priority: Minor
>
> Using collection constructors in select clause of HQL (e.g. new map(...)) generates n + 1 SQL statements (one for primary keys, one for each object).
> This is a problem when there're clauses as "distinct" and "order by":
> select distinct o from MyEntity o order by o.description
> works, because in the generated SQL all the columns are mapped in the select clause; but:
> select distinct new map (o as result) from MyEntity o order by o.description
> doesn't work, because the first line of generated SQL is like:
> select distinct id from MyTable order by description
> and that's invalid sql (at least in Oracle): description shoud be placed in select clause.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 2 months
[Hibernate-JIRA] Commented: (ANN-252) AnnotationConfiguration silently ignores classes that are annotated with wrong Entity, or not annotated.
by Emmanuel Bernard (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-252?page=co... ]
Emmanuel Bernard commented on ANN-252:
--------------------------------------
it is highlighted in the doc
> AnnotationConfiguration silently ignores classes that are annotated with wrong Entity, or not annotated.
> --------------------------------------------------------------------------------------------------------
>
> Key: ANN-252
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-252
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Affects Versions: 3.1beta8
> Reporter: Damon Feldman
> Assignee: Emmanuel Bernard
> Fix For: 3.3.0.ga
>
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> If you import the wrong Entity (e.g. org.hibernate.annotation.Entity) in a persistent class, the class is ignored, but no logging or other notification is made of the issue.
> Recommend: adding a log statement:
> log.warn("The class" + annotatedClass.getName() +"does not have the proper annotation: " + Entity.class.getName());
> Here is the code that seems responsible:
> /**
> * Read a mapping from the class annotation metadata (JSR 175).
> *
> * @param persistentClass the mapped class
> * @return the configuration object
> */
> public AnnotationConfiguration addAnnotatedClass(Class persistentClass) throws MappingException {
> try {
> if ( persistentClass.isAnnotationPresent( Entity.class ) ) {
> annotatedClassEntities.put( persistentClass.getName(), persistentClass );
> }
> annotatedClasses.add( persistentClass );
> return this;
> }
> catch (MappingException me) {
> log.error( "Could not compile the mapping annotations", me );
> throw me;
> }
> }
--
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
18 years, 2 months