-->
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: Another TrasientObjectException problem...
PostPosted: Tue Dec 19, 2006 8:29 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Hibernate version: 3.1

Name and version of the database you are using:Oracle 10g


I read a lot around here, and even some documents, trying to avoid posting... but I couldn't find exactly what is happening.

I have the following structure of tables I'm trying to persist.

table

-class
--properties
---keyproperties
--keyproperties
--componentfiled
--association (Begin/End)
---column/association

-componentclass
--properties
--componentfield (Begin/End)

-column
--properties
--column/association

where: no line: top object
1 line: under the top
2 lines: under the imediate 1 line object
Same names, mean same object/table

"Under" means a direct one-to-many relation with the one above.

Starting on info on a table and info on it's columns, I'm trying to create a metadata database.

I have these 5 cases where a information line my program reads could be:
1) A common column
2) A PK column
3) A FK column
4) A column related to a component class
5) No column/propertie at all, a listing of an transition component class ( a component class with no fields, just linking to others).

All of them are tested and work, but only case 4 generates a TrasientObjectException (and does not work ). The stack trace points the ComponentClass POJO as the source of the exception. But tells nothing more (I've seen many stacktraces around telling "save <this> first" or similar things.

The structure of component class works like this:
The component fields connect either a class with a component class OR a componentclass (Begin) with a child componentclass (End)

The component class is also linked with the properties it represents. But when I need to save the properties, I just "add" them all to the respective columns.

Every single one-to-many association in my mapping files are cascade-all.

I tried to save the componentfields separetedly but it ended up with the same problem.

Someone has any idea of what's happening?

A note: I add everything up to the table object and save only it.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 19, 2006 3:14 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
I decided to post the stack trace to help you help me.

I just hope it helps:

Exception in thread "main" org.hibernate.TransientObjectException: persistencia.pojo.hbm.ClassesComponente
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at persistencia.dao.BdTesteDaoImpl.gravaTudo(BdTesteDaoImpl.java:131)
at base.processos.ProcessaCasos.salvaTabela(ProcessaCasos.java:663)
at base.processos.GeradorPrincipal.gerar(GeradorPrincipal.java:159)
at base.controle.GeradorScripts.executar(GeradorScripts.java:39)
at base.controle.GeradorScripts.main(GeradorScripts.java:27)

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 19, 2006 3:50 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
It seems like a problem in your component mapping. Did you verify your mapping. A good way to see if it is correct is to try to generate your SQL from the hbm.xml files with SchemaUpdate, see http://www.hibernate.org/hib_docs/v3/re ... guide-s1-3

If you don't find the problem this way, please post your mappings.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 6:17 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
We created the mappings through a tool called Schema2DDL.

And we used another similar tool to create the POJOs from the mappings.

I find it hard to belive the mappings are the problem, not just because they were automaticaly generated but because we have been using them in other programs (that access the same database) for some 4 or more months rith now.

But, since you called my atention to that, I may try to check it or even regenerate them. This base suffered some modifications a few days ago and the new automatic generated HBM/POJOs may not be so correct.

Anyway, if anyone has another lead on this, please post.

EDIT: Ops! I made a mistake. The tool is called Middlegen. Version 2.1. And the tool used to generate the pojos is called HBM2Java.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 8:57 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
I've regenerated the HBM and the POJOs.

Results were the same.

I decided to create a small test class that creates and saves all the relations and details that are created within the defective case of my program.

It worked perfectly. So it isn't the mapping the problem.

What I don't get is what in my code could generate such a problem, if the mapping is right?

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 2:38 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Solved!

After a little comment/uncomment line testing I figured that Hibernate was not the problem. The stack trace just led me to think that.

It was actually a silly programming error where under certain circunstances I was setting an empty Component Class to a Property.

Almost 3 days to realize that! :(

_________________
Falci - Heavy Worker!


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.