-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Cannot commit using UserCollectionType and debug logging
PostPosted: Tue Apr 05, 2005 12:20 pm 
Newbie

Joined: Thu Jan 06, 2005 11:56 am
Posts: 10
I am specifying a UserCollectionType and turn on log4j debug tracing.
It gets past this point without debug tracing (but I haven't got my UserCollectionType working end to end yet).
Note that there are 22 usages of CustomCollectionType.getReturnedClass and the 4 usages in the org.hibernate.type package look suspiciously like they will throw the exception below at various times.

I have one issue with the UserCollectionType interface. When Hibernate instantiates a new instance of the UserCollection it does not pass in the "owning" object of the collection. Prevents using Hibernate to persist EMF objects. More on this later after I get it working end-to-end.

java.lang.UnsupportedOperationException: not defined for custom collection types
at org.hibernate.type.CustomCollectionType.getReturnedClass(CustomCollectionType.java:55)
at org.hibernate.type.CollectionType.toLoggableString(CollectionType.java:137)
at org.hibernate.pretty.Printer.toString(Printer.java:53)
at org.hibernate.pretty.Printer.toString(Printer.java:90)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:91)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)

(rest of stack trace removed to protect the innocent)


Top
 Profile  
 
 Post subject: RE: Cannot commit using UserCollectionType and debug logging
PostPosted: Fri May 27, 2005 9:46 am 
Newbie

Joined: Fri May 27, 2005 9:36 am
Posts: 2
I have run into this problem as well. The toLoggableString method in CollectionType is the offender. It's not taking into account that CustomCollectionType throws an UnsupportedOperationException in getReturnedClass(). Did you ever get a reply concerning this? I didn't see anything in JIRA that seemed to pertain to this issue.

Code:
   public String toLoggableString(Object value, SessionFactoryImplementor factory)
         throws HibernateException {

      if ( value == null ) return "null";
      
      if ( Hibernate.isInitialized( value ) ) {
         [b]if ( getReturnedClass().isInstance(value) ) {[/b]            List list = new ArrayList();
            Type elemType = getElementType( factory );
            Iterator iter = getElementsIterator( value );
            while ( iter.hasNext() ) {
               list.add( elemType.toLoggableString( iter.next(), factory ) );
            }
            return list.toString();
         }
         else {
            // for DOM4J "collections" only
            return ( (Element) value ).asXML(); //TODO: it would be better if this was done at the higher level by Printer
         }
      }
      else {
         return "<uninitialized>";
      }
      
   }


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 10:05 am 
Newbie

Joined: Thu Jan 06, 2005 11:56 am
Posts: 10
It is still a problem. I didn't file anything in JIRA either. They seem to require alot of information that I didn't have time to setup. Sorry. The Class name should simply come from the meta-model (the class attribute of the many-to-one in the Hibernate mapping file).

I also still have an issue with UserCollectionType.
UserCollectionType needs the following method signature changed to
PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key)
in order to get the correct owning (EMF) object instance for the collection.
This is a trivial change to Hibernate (I wish none had to be made).

I am having difficulties getting EMF and Hibernate to integrate. They both support lazy loading collections and a single implementation class has to work in both frameworks. EMF must own the instantiation of the Hibernate lazy loading collection type. I haven't had alot of time to investigate this further.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 5:35 pm 
Newbie

Joined: Fri May 27, 2005 9:36 am
Posts: 2
I was notified that this issue was resolved earlier today (JIRA Issue - HHH 547). The changes are in CVS.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.