-->
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.  [ 6 posts ] 
Author Message
 Post subject: Mappings Erros: How to track down?
PostPosted: Tue Oct 21, 2003 4:31 pm 
Newbie

Joined: Wed Oct 15, 2003 4:31 pm
Posts: 17
Howdy,

As a reasonably new developer with Hibernate, I find that a great deal of the problems I'm having turn out to be mapping configuration file problems. Sometimes the reason is obvious, but often it's not.

Unfortunatly, trying to determine where the error is coming from is very difficult. I usually get a stack trace, but there isn't a good way to determine what property or even class is the source of the problem. Short extract: Right now I'm trying to track down a problem generating this stack trace:

net.sf.hibernate.MappingException: No persister for: java.lang.Integer
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:315)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2555)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2562)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2624)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:65)
at net.sf.hibernate.type.EntityType.isDirty(EntityType.java:140)
at net.sf.hibernate.type.TypeFactory.findDirty(TypeFactory.java:225)
at net.sf.hibernate.persister.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:247)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2387)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2345)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2223)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2210)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at SOpen.common.util.AppSessionContext.commitTransaction(AppSessionContext.java:382)
at local.gerry.SPMTest.doTest(SPMTest.java:178)
at local.gerry.SPMTest.main(SPMTest.java:207)

It seems obvious that it's a mapping error, but I don't know which of the 8 classes in use at the time of this error (hibernate data classes) is the cause, much less the property causing it.

Is there any way to tell hibernate to dump an identifier of what class.property it was working on when it encounters an error? If I knew for sure what was the source of the problem, even if I didn't understand why, I could focus all my attention on it and probably resolve it via searches and FAQs (vs bugging folks).

Is there any helpful debug options I can enable? I have all the hibernate debugging messages I'm aware of already enabled and while there is a lot of good debugging info created, none of it helps to pinpoint where this exception is coming from.

Gerry


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 4:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is not necessarily a mapping problem. This exception often occurs if you try to continue using a session after an exception occurred while loading an object.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 4:56 pm 
Newbie

Joined: Wed Oct 15, 2003 4:31 pm
Posts: 17
gavin wrote:
This is not necessarily a mapping problem. This exception often occurs if you try to continue using a session after an exception occurred while loading an object.


What sort of load exceptions can do this? I'm attempting to load a record (via session.load(x,y)) and when that fails (and it does - that is not a problem), I then create a new object to save in the database. So there is an exception, but not a "fatal" one (well, I guess that is from my perspective - I guyess I'm not sure that such a thing wouldn't make hibernate unhealthy).

If that sort of exception (a failied load()) can cause this, is there a proper way to handle a failed load that doesn't invalidate the entire session?

Gerry


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 8:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ALL hibernate exceptions are fatal! (As per the documentation.)

Looks to me like you should be using a query, or else Session.get() instead of Session.load().


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 12:55 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
Doesn't this happen with session.load(), if your ID field in the mapping is a primitive type? Since session.load(x, y) requires that y be serializable, i.e. a Wrapper type.

I remember getting something like this once when I still used primitives as my primary key types.

-G


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 10:25 am 
Newbie

Joined: Wed Oct 15, 2003 4:31 pm
Posts: 17
Howdy,

Thanks all - turns out that it wasn't a problem with a specific field but in fact an exception that was being caught but should have caused an error. I fixed that and converted over to a get() for my existings testing and will heed the "any exception is bad" philosophy :-)

Still, back to my original question, is there a way to find out what field is giving hibernate fits when wierd things do happen?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.