[Hibernate-JIRA] Created: (HHH-7071) Error during a entity collection loading - wrong SQL query generation - missing discriminator condition in the "where" clause if associated class has discriminator force=true
by Nicolas Bouillon (JIRA)
Error during a entity collection loading - wrong SQL query generation - missing discriminator condition in the "where" clause if associated class has discriminator force=true
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-7071
URL: https://hibernate.onjira.com/browse/HHH-7071
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 4.0.1, 3.5.6
Environment: MySQL, Hibernate 3.5.6 or 4.0.1
Reporter: Nicolas Bouillon
Priority: Critical
Given an abstract parent class :
<class abstract="true"
name="pojo.Product" table="Product">
<id column="ID" name="id">
<generator class="native" />
</id>
<discriminator column="type" type="java.lang.String"
force="true" />
[...]
and one (or more) subclasses, defined in a separate file :
<subclass discriminator-value="Childroduct"
extends="pojo.Product"
lazy="true" name="pojo.plugin.ChildProduct">
<join fetch="join" table="ChildProduct">
<key column="productID" />
[...]
The separate file can be loaded or not in the hibernate configuration, with a plugin system. That's why force=true was placed on the discriminator element.
Given this class that have a relationship with the parent class :
<class name="pojo.ProductCategory">
<id column="ID" name="id">
<generator class="native"/>
</id>
<property name="code"/>
<property name="description"/>
<bag name="products" table="product_productcategory">
<key column="productCategoryID"/>
<many-to-many class="pojo.Product" column="productID" />
</bag>
</class>
The following code throws an exeception :
ProductCategory pc = productCategoryDao.findById(1);
for (Product product: pc.getProducts()) {
System.out.println(product.getId());
}
Caught: org.hibernate.WrongClassException: Object with id: 592 was not of the specified subclass: pojo.Product (Discriminator: ChildProduct)
org.hibernate.WrongClassException: Object with id: 592 was not of the specified subclass: pojo.Product (Discriminator: ChildProduct)
at org.hibernate.loader.Loader.getInstanceClass(Loader.java:1626)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1460)
at org.hibernate.loader.Loader.getRow(Loader.java:1384)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:640)
at org.hibernate.loader.Loader.doQuery(Loader.java:856)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2175)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:61)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:622)
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:82)
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1606)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:379)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
at org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:266)
The generated SQL to load the Product collection doesn't contains a WHERE clause to limit the result to known discriminators values.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-7046) Polymorphic query by natural ID broken
by Emanuel Kupcik (JIRA)
Polymorphic query by natural ID broken
--------------------------------------
Key: HHH-7046
URL: https://hibernate.onjira.com/browse/HHH-7046
Project: Hibernate ORM
Issue Type: Bug
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
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-7066) Improve memory allocation on String extraction out of Clob fields
by Sanne Grinovero (JIRA)
Improve memory allocation on String extraction out of Clob fields
-----------------------------------------------------------------
Key: HHH-7066
URL: https://hibernate.onjira.com/browse/HHH-7066
Project: Hibernate ORM
Issue Type: Improvement
Reporter: Sanne Grinovero
Assignee: Sanne Grinovero
Fix For: 4.1.1
Attachments: Overhead of DataHelper String extraction from Clob.png
Extracting a large String out of a Clob makes use of the org.hibernate.type.descriptor.java.DataHelper, which allocats StringBuilder to create the extracted String instances.
Adjusting the initial size of the StringBuilder according to expected / known data size can have a good performace impact, as shown in the attached screenshot from a profiler session.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-7070) Sybase15+ dialect -> dateadd, datediff, SQLFunctionTemplate lack templates
by Stanimir Simeonoff (JIRA)
Sybase15+ dialect -> dateadd, datediff, SQLFunctionTemplate lack templates
--------------------------------------------------------------------------
Key: HHH-7070
URL: https://hibernate.onjira.com/browse/HHH-7070
Project: Hibernate ORM
Issue Type: Bug
Affects Versions: 3.6.10
Reporter: Stanimir Simeonoff
SybaseASE15Dialect dialect contains a lot of functions (datediff, dateadd just to mention few) defined as template ones but missing the template arguments. That results into absolutely wrong rendering.
for example the functions should be:
registerFunction( "dateadd", new SQLFunctionTemplate( StandardBasicTypes.TIMESTAMP, "dateadd(?1, ?2, ?3)" ) );
registerFunction( "datediff", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datediff(?1, ?2, ?3)" ) );
morealso SQLFunctionTemplate shall not take no arguments function, that's it lacking '?' into the template. Such a change would allow detecting the errors fast.
A possible workaround is subclassing the Dialect and fixing the problem (something I presently do)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 1 month
[Hibernate-JIRA] Created: (HHH-2965) When using Criteria.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP) method aliases need to be optional
by Ittai Zeidman (JIRA)
When using Criteria.setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP) method aliases need to be optional
----------------------------------------------------------------------------------------------------------------------
Key: HHH-2965
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2965
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: 3.2.2 Oracle 10G
Reporter: Ittai Zeidman
Priority: Critical
now when using the CriteriaSpecification- ALIAS_TO_ENTITY_MAP the convertion to map is using the aliases array, if it does not find an alias for the property it is not included in the map. I think that if no alias is defined then the propertyName attribute needs to be assigned as the key for the value in the hashmap.
I came across this issue as i have many mapped entities in my system and when using projections i need to use the resultTransformer. this is critical as when using aliases it is duplicated not only to the select clause but to the where clause only which is another open bug (#HB-1331). If one bug is closed then the other can be considered as minor as i can give aliases to every property i need if it does not affect my where 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
14 years, 1 month