Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

praveen potty

Greenhorn
+ Follow
since Jun 08, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by praveen potty

Hi All,
I was able to solve the problem
my parent object set contained the string attibutes which actually should have contained the child objects.

sorry for my folly

Thanks
praveen
Hi ,

I am sorry to give you one more information
I am using the HIbernateDAO support for my DAO classes.
ie my DAO class extends HibenateDAOSupport

thanks
Praveen
Hi,
The exception is thrown when it tries to access the getter method of child class

As you may be aware there are two child class
1. BaseTbNewsCodeChild
2.BaseTbNewsCodeChildId

if you see the below exception it says that error occured calling the getter method of child class.id. I am not able to understand this.
When I debugged the program the Parent object,at the time of
session.save(), has the child class attributes in the set(The parent object has a set(hashset)attribute which has the value of the child as a string object).
I assume that the Hibernate will set the id and other properties of the child when we save the parent. but it it is not happening for me.


org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.ert.nwcs.symbology.dataaccess.base.BaseTbNewsCodeChild.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:460)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:290)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.engine.Cascade.cascade(Cascade.java:223)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.cascadeOnUpdate(DefaultSaveOrUpdateEventListener.java:331)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:303)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:216)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:509)
at com.dowjones.nwcs.symbology.dataaccess.dao.TbNewsCodeDAOImpl.insertRecords(TbNewsCodeDAOImpl.java:31)
at com.dowjones.nwcs.symbology.service.SymbologyServiceImpl.SynchronizeTables(SymbologyServiceImpl.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:165)
at $Proxy2.SynchronizeTables(Unknown Source)
at com.dowjones.nwcs.symbology.service.CodeServiceImpl.SynchronizeTables(CodeServiceImpl.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:165)
at $Proxy0.SynchronizeTables(Unknown Source)
at com.dowjones.nwcs.symbology.scheduler.FileProcessor.updateTables(FileProcessor.java:1052)
at com.dowjones.nwcs.symbology.scheduler.FileProcessor.processWeeklyNewsCodeFiles(FileProcessor.java:388)
at com.dowjones.nwcs.symbology.scheduler.FileProcessor.processWeeklyContentDO(FileProcessor.java:189)
at com.dowjones.nwcs.symbology.scheduler.FileProcessor.processWeeklyFiles(FileProcessor.java:178)
at com.dowjones.nwcs.symbology.scheduler.FileProcessor.processFiles(FileProcessor.java:54)
at com.dowjones.nwcs.symbology.scheduler.WeeklyFileDownloader.getfile(WeeklyFileDownloader.java:37)
at com.dowjones.nwcs.symbology.scheduler.WeeklyFileDownloader.main(WeeklyFileDownloader.java:27)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
... 51 more
Hi
I am facing a problem with the Hibernate framework.
I have a parent table and associate child table
When I try to insert a record to the Parent it is not inserting the record to the child.It is getting inserted to the parent.
I am not getting any exception also
I am using sesson.save(parent object).

do I need to explicitly do session.save(child object)?
mapping xml for the parent

<hibernate-mapping package="com.ert.nwcs.symbology.dataaccess">
<class name="TbNewsCode" table="TB_NEWS_CODE" schema="NWCS">
<id name="newsCodeId" type="big_decimal">
<column name="NEWS_CODE_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<property name="newsCode" type="string">
<column name="NEWS_CODE" length="10" not-null="true" />
</property>
<property name="newsType" type="big_decimal">
<column name="NEWS_TYPE" precision="22" scale="0" not-null="true" />
</property>
<set name="tbNewsCodeChild" inverse="true" >
<key>
<column name="NEWS_CODE_ID" precision="22" scale="0" not-null="true" />
</key>
<one-to-many class="TbNewsCodeChild" />
</set>
</class>
</hibernate-mapping>

mapping xml for child

<hibernate-mapping package="com.ert.nwcs.symbology.dataaccess">
<class name="TbNewsCodeParent" table="TB_NEWS_CODE_CHILD" schema="NWCS">
<composite-id name="id" class="TbNewsCodeChildId">
<key-many-to-one name="tbNewsCode" class="TbNewsCode">
<column name="NEWS_CODE_ID" precision="22" scale="0" />
</key-many-to-one>
<key-property name="childCode" type="string">
<column name="CHILD_CODE" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

Please help me resolve this problem.
I tried using cascade="all" or cascade ="save-update" option in the parent mapping xml, but it is giving me some error when it tries to access the getter method of child