-->
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: invocationTargetException after update
PostPosted: Mon May 15, 2006 12:56 pm 
Newbie

Joined: Mon May 15, 2006 12:27 pm
Posts: 3
Location: Paris
Hibernate version: 3.0
Name and version of the database you are using:Oracle 9i


Hello there !

I use AppFuse for my application.
My problem append when I read a record in my database, I update it without modification (just for testing), I read it again in db with the same query and I have an InvocationTargetException on each property of a composite object.


Here is a part of the mapping of my class FacConsolidation.class with a composite id.
Code:
<composite-id name="id" class="com.myapp.model.facturation.FacConsolidationId">
            <key-many-to-one name="facPlic" class="com.myapp.model.facturation.FacPlic">
                <column name="IDPLIC" precision="6" scale="0" />
            </key-many-to-one>
            <key-property name="annee" type="integer">
                <column name="ANNEE" precision="4" scale="0" />
            </key-property>
            <key-property name="mois" type="integer">
                <column name="MOIS" precision="2" scale="0" />
            </key-property>
</composite-id>
...
...

facPlic is an objet with an id and parameters.
I read it from my record of FacConsolidation (facConsolidation.getId().getFacPlic())
I'm able to read each properties of FacPlic object before updating but only its id after the update; I have an invocationTargetException.

Thanks for those who will read...and answer to this problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 15, 2006 1:30 pm 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
eventhough i don't see it in your post i assume that the getters and setters for your integer attributes use the 'int' java type.

this causes a classic problem with an invocation exception when the ints don't have default values in the db. hibernate gets a null from the db and will try to set it on your pojo with setBlah(null).

if your integer values can be null in the db, consider using Integer datatype instead of int.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 4:22 am 
Newbie

Joined: Mon May 15, 2006 12:27 pm
Posts: 3
Location: Paris
Thanks ravi to answser my problem.
Unfortunately, this is not solve it. Actually I've allready had the problem you describe so I only use instantiable objects in my getters & setters.

To describe more the problem :

FacConsolidation contains a FacConsolidationId property (composite pk in db)
FacConsolidationId conaints a FacPlic property
FacPlic contains a ConPdf property.
ConPdf contains an Integer 'id' (pk) and a String 'code'.

In the first part I read a FacConsolidation record and it's OK.
I update it and it's OK
I read it again and the problem occurs :

When I read my FacConsolidation record
I'm able to reach FacConsolidationId, FacPlic and ConPdf.id
but ConPdf.code cause an InvocationTargetException.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 9:00 am 
Newbie

Joined: Mon May 15, 2006 12:27 pm
Posts: 3
Location: Paris
I've solved my problem..

after I display my formBean in my jsp and validate the formular, I have a convertFormToBean method to populate my POJO FacConsolidation

In this method, I populate FacConsolidationId (composite pk of FacConsolidation) and FacPlic.id (pk) but not FacPlic.code

I thought that Hibernate will be able to populate FacPlic.code by itself but I was wrong (perhaps due to my mapping params).

I just have to add a method getFacPlic(id) to get the FacPlic POJO with all its attributes.


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.