[Hibernate-JIRA] Created: (HHH-2757) Cascade.cascadeCollectionElements ClastCastException for non-entity element types
by Alan Krueger (JIRA)
Cascade.cascadeCollectionElements ClastCastException for non-entity element types
---------------------------------------------------------------------------------
Key: HHH-2757
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2757
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.2
Environment: Hibernate 3.2.2.ga with PostgreSQL 8.2
Reporter: Alan Krueger
When trying to flush changes in EntityMode.DOM4J, a composite element causes a ClassCastException in Cascade.cascadeCollectionElements when invoked by Cascade.cascadeCollection. The latter allows the call to the former when the element is of ComponentType, but assumes in the former always casts to EntityType if EntityMode.DOM4J is in effect.
Possible patch:
diff -u -r1.1 Cascade.java
--- src/org/hibernate/engine/Cascade.java 3 Jul 2007 20:12:01 -0000 1.1
+++ src/org/hibernate/engine/Cascade.java 30 Jul 2007 19:42:54 -0000
@@ -281,7 +281,7 @@
final boolean isCascadeDeleteEnabled) throws HibernateException {
// we can't cascade to non-embedded elements
boolean embeddedElements = eventSource.getEntityMode()!=EntityMode.DOM4J ||
- ( (EntityType) collectionType.getElementType( eventSource.getFactory() ) ).isEmbeddedInXML();
+ ( elemType.isEntityType() && ( (EntityType) elemType ).isEmbeddedInXML() );
boolean reallyDoCascade = style.reallyDoCascade(action) &&
embeddedElements && child!=CollectionType.UNFETCHED_COLLECTION;
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-2756) PostLoadEventListener is triggered on not fully loaded entity
by Roman Pichlík (JIRA)
PostLoadEventListener is triggered on not fully loaded entity
-------------------------------------------------------------
Key: HHH-2756
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2756
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4.sp1
Reporter: Roman Pichlík
Priority: Minor
PostLoadEventListener is triggered, but entity is not fully loaded especially is not possible to operate on mapped collection because org.hibernate.LazyInitializationException: illegal access to loading collection is thrown. PostLoadEventListener should be triggered when is entity fully loaded.
Let say, we have Parent, Child entity and PostLoadEventListener which iterates over child collection.
public class Parent {
private Set<Child> children;
}
public class PostLoadEventListener implements PostLoadEventListener {
public void onPostLoad(PostLoadEvent event) {
Parent parent = (Parent) event.getEntity();
for(Child child: parent.getChildren()){ // org.hibernate.LazyInitializationException: illegal access to loading collection
System.out.println(child);
}
}
}
Fix tip: see org.hibernate.loader.Loader#initializeEntitiesAndCollections, if i understood well the key are following statements.
if ( hydratedObjects!=null ) {
int hydratedObjectsSize = hydratedObjects.size();
if ( log.isTraceEnabled() ) {
log.trace( "total objects hydrated: " + hydratedObjectsSize );
}
for ( int i = 0; i < hydratedObjectsSize; i++ ) {
TwoPhaseLoad.initializeEntity( hydratedObjects.get(i), readOnly, session, pre, post ); //event is trigerred here
}
}
//but collection are loaded by this code
if ( collectionPersisters != null ) {
for ( int i=0; i<collectionPersisters.length; i++ ) {
if ( !collectionPersisters[i].isArray() ) {
endCollectionLoad( resultSetId, session, collectionPersisters[i] );
}
}
}
//post event handlers should be trigerred here
--
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, 5 months
[Hibernate-JIRA] Created: (HHH-2754) Inner classes in methods cannot be used in select clause when with conjunction with "typesafe Java object" mechanism
by Adam Wozniak (JIRA)
Inner classes in methods cannot be used in select clause when with conjunction with "typesafe Java object" mechanism
--------------------------------------------------------------------------------------------------------------------
Key: HHH-2754
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2754
Project: Hibernate3
Issue Type: New Feature
Affects Versions: 3.2.4.sp1
Reporter: Adam Wozniak
Hello
Here in the documentation to Hibernate Core:
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#queryhql-s...
... we have a following example:
select new Family(mother, mate, offspr)
from DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
But this mechanism doesn't work when Family class is defined as inner class in a method.
So when I wrote something like this:
void myBusinessMethod()
{
class Family3
{
private String rowid;
private long coId;
private int csSeqno;
public Family3()
{
//
}
@SuppressWarnings("unused")
public Family3(
final String rowid
, final long coId
, final int csSeqno
)
{
//System.out.println("ssss");
this.rowid = rowid;
this.coId = coId;
this.csSeqno = csSeqno;
}
}
... and within this method I'm trying to do this:
query = sess.createQuery(
"select new typesafe_Java_object.TypesafeJavaObjectEMRWTest$1Family3(t.id, t.coId, t.csSeqno) from BSCSCgTaroptLog t");
list = query.list();
... then I'm slapped by a following exception:
org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [typesafe_Java_object.TypesafeJavaObjectEMRWTest$1Family3] [select new typesafe_Java_object.TypesafeJavaObjectEMRWTest$1Family3(t.id, t.coId, t.csSeqno) from pl.capgemini.tme.bonobo.model.BSCSCgTaroptLog t]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
(...)
So the question is:
Is it possible to add another method to org.hibernate.Session:
public Query createQuery(String queryString, FactoryType factoryToGenerateMyInnerEntities)
???
Why do I need such mechanism? I rewriting a legacy system (Oracle PL/SQL) and I have many different HQL queries. To use "typesafe Java object" I must make my mediate classes static. But then I would have a kind of class bloat. And this is the reason why I would like to hide those classes and make them much more locally (for example inside my one single java method).
Kind regards,
Adam Wozniak
--
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, 5 months
[Hibernate-JIRA] Created: (HSEARCH-90) negative List capacity in FullTextQueryImpl.list()
by Sheldon Shi (JIRA)
negative List capacity in FullTextQueryImpl.list()
--------------------------------------------------
Key: HSEARCH-90
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-90
Project: Hibernate Search
Issue Type: Bug
Components: query
Affects Versions: 3.0.0.beta3
Reporter: Sheldon Shi
Priority: Minor
I did this query:
fullTextQuery.setFirstResult(sr.getOffset());
fullTextQuery.setMaxResults(sr.getLength());
List results = fullTextQuery.list();
sr.getOffset() and sr.getLength() are pagination parameters. They happened to be carried from another query as a session properties (not the right thing to do here but it happened). In my case offset was 10 and length was 10. The new search result is empty, so these lines of code in FullTextQueryImpl gave a negative capacity for list exception:
int first = first();
int max = max( first, hits );
Session sess = (Session) this.session;
List<EntityInfo> infos = new ArrayList<EntityInfo>( max - first + 1);
because max=-1 and first=10. Would it be nice if a check is done before assign List capacities?
--
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, 5 months