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: HELP PLEASE... SOMEBODY
PostPosted: Thu Apr 27, 2006 3:10 am 
Newbie

Joined: Thu Apr 27, 2006 2:46 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="transactions.TransactionElement" table="TRANSACTIONS">
<id name="txn_no" column="TRANSACTION_NO">
<generator class="assigned"/>
</id>

<many-to-one name="references1" class="transactions.Reference1"
cascade="none" outer-join="auto" update="true" insert="true"
column="REFERENCE1_CODE" lazy="false"/>

</class>

<class name="transactions.Reference1" table="REFERENCE1">
<id name="ref1_code" column="REFERENCE1_CODE">
<generator class="assigned"/>
</id>
<property name="ref_desc" column="REFERENCE_DESCRIPTION"/>

<set name="references1" table="TRANSACTIONS" lazy="false">
<key column="REFERENCE1_CODE" />
<one-to-many class="transactions.TransactionElement"/>
</set>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
TransactionElement aTransaction = new TransactionElement();
aTransaction.setTxn_no(nTransactions);
aTransaction.setReferences1(refa);
aTransaction.setReferences2(refb);
aTransaction.setReferences3(refc);
session.save(aTransaction);
session.getTransaction().commit();


Full stack trace of any exception that occurs:

14:30:30,578 INFO HbmBinder:309 - Mapping class: transactions.TransactionElement -> TRANSACTIONS
14:30:30,734 INFO HbmBinder:309 - Mapping class: transactions.Child1 -> CHILD1
14:30:30,734 INFO HbmBinder:309 - Mapping class: transactions.Child2 -> CHILD2
14:30:30,734 INFO HbmBinder:309 - Mapping class: transactions.Child3 -> CHILD3
14:30:30,734 INFO HbmBinder:309 - Mapping class: transactions.Reference1 -> REFERENCE1
14:30:30,750 INFO HbmBinder:309 - Mapping class: transactions.Reference2 -> REFERENCE2
14:30:30,750 INFO HbmBinder:309 - Mapping class: transactions.Reference3 -> REFERENCE3
14:30:30,750 INFO Configuration:1419 - Configured SessionFactory: null
14:30:30,750 INFO HbmBinder:2349 - Mapping collection: transactions.TransactionElement.firstChildren -> CHILD1
14:30:30,765 INFO HbmBinder:2349 - Mapping collection: transactions.TransactionElement.secondChildren -> CHILD2
14:30:30,765 INFO HbmBinder:2349 - Mapping collection: transactions.TransactionElement.thirdChildren -> CHILD3
14:30:30,765 INFO HbmBinder:2349 - Mapping collection: transactions.Reference1.references1 -> TRANSACTIONS
14:30:30,765 INFO HbmBinder:2349 - Mapping collection: transactions.Reference2.references2 -> TRANSACTIONS
14:30:30,765 INFO HbmBinder:2349 - Mapping collection: transactions.Reference3.references3 -> TRANSACTIONS
14:30:30,781 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
14:30:30,781 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
14:30:30,781 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
14:30:30,781 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost
14:30:30,781 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
14:30:30,937 INFO SettingsFactory:77 - RDBMS: HSQL Database Engine, version: 1.8.0
14:30:30,937 INFO SettingsFactory:78 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
14:30:30,968 INFO Dialect:103 - Using dialect: org.hibernate.dialect.HSQLDialect
14:30:31,000 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
14:30:31,000 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
14:30:31,000 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
14:30:31,000 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
14:30:31,000 INFO SettingsFactory:136 - JDBC batch size: 15
14:30:31,000 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
14:30:31,000 INFO SettingsFactory:144 - Scrollable result sets: enabled
14:30:31,000 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
14:30:31,000 INFO SettingsFactory:160 - Connection release mode: auto
14:30:31,015 INFO SettingsFactory:187 - Default batch fetch size: 1
14:30:31,015 INFO SettingsFactory:191 - Generate SQL with comments: disabled
14:30:31,015 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
14:30:31,015 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:30:31,015 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
14:30:31,015 INFO SettingsFactory:203 - Query language substitutions: {}
14:30:31,015 INFO SettingsFactory:209 - Second-level cache: enabled
14:30:31,015 INFO SettingsFactory:213 - Query cache: disabled
14:30:31,015 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
14:30:31,015 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
14:30:31,015 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
14:30:31,031 INFO SettingsFactory:257 - Echoing all SQL to stdout
14:30:31,031 INFO SettingsFactory:264 - Statistics: disabled
14:30:31,031 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
14:30:31,031 INFO SettingsFactory:283 - Default entity-mode: pojo
14:30:31,078 INFO SessionFactoryImpl:153 - building session factory
14:30:31,718 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
14:30:31,734 INFO SchemaExport:155 - Running hbm2ddl schema export
14:30:31,734 DEBUG SchemaExport:173 - import file not found: /import.sql
14:30:31,734 INFO SchemaExport:182 - exporting generated schema to database
14:30:31,734 DEBUG SchemaExport:296 - alter table CHILD1 drop constraint FK766DA2B5FA892A59
14:30:31,734 DEBUG SchemaExport:296 - alter table CHILD2 drop constraint FK766DA2B6FA892A59
14:30:31,750 DEBUG SchemaExport:296 - alter table CHILD3 drop constraint FK766DA2B7FA892A59
14:30:31,750 DEBUG SchemaExport:296 - alter table TRANSACTIONS drop constraint FKFE9871555CED4E25
14:30:31,750 DEBUG SchemaExport:296 - alter table TRANSACTIONS drop constraint FKFE9871555B387585
14:30:31,750 DEBUG SchemaExport:296 - alter table TRANSACTIONS drop constraint FKFE98715559839CE5
14:30:31,750 DEBUG SchemaExport:296 - drop table CHILD1 if exists
14:30:31,750 DEBUG SchemaExport:296 - drop table CHILD2 if exists
14:30:31,750 DEBUG SchemaExport:296 - drop table CHILD3 if exists
14:30:31,750 DEBUG SchemaExport:296 - drop table REFERENCE1 if exists
14:30:31,750 DEBUG SchemaExport:296 - drop table REFERENCE2 if exists
14:30:31,750 DEBUG SchemaExport:296 - drop table REFERENCE3 if exists
14:30:31,765 DEBUG SchemaExport:296 - drop table TRANSACTIONS if exists
14:30:31,765 DEBUG SchemaExport:296 - create table CHILD1 (CHILD1_ID integer not null, DESCRIPTION1 varchar(255), DESCRIPTION2 varchar(255), DESCRIPTION3 varchar(255), TRANSACTION_NO integer, primary key (CHILD1_ID))
14:30:31,765 DEBUG SchemaExport:296 - create table CHILD2 (CHILD2_ID integer not null, DESCRIPTION1 varchar(255), DESCRIPTION2 varchar(255), DESCRIPTION3 varchar(255), TRANSACTION_NO integer, primary key (CHILD2_ID))
14:30:31,765 DEBUG SchemaExport:296 - create table CHILD3 (CHILD3_ID integer not null, DESCRIPTION1 varchar(255), DESCRIPTION2 varchar(255), DESCRIPTION3 varchar(255), TRANSACTION_NO integer, primary key (CHILD3_ID))
14:30:31,765 DEBUG SchemaExport:296 - create table REFERENCE1 (REFERENCE1_CODE varchar(255) not null, REFERENCE_DESCRIPTION varchar(255), primary key (REFERENCE1_CODE))
14:30:31,781 DEBUG SchemaExport:296 - create table REFERENCE2 (REFERENCE2_CODE varchar(255) not null, REFERENCE_DESCRIPTION varchar(255), primary key (REFERENCE2_CODE))
14:30:31,781 DEBUG SchemaExport:296 - create table REFERENCE3 (REFERENCE3_CODE varchar(255) not null, REFERENCE_DESCRIPTION varchar(255), primary key (REFERENCE3_CODE))
14:30:31,781 DEBUG SchemaExport:296 - create table TRANSACTIONS (TRANSACTION_NO integer not null, REFERENCE1_CODE varchar(255), REFERENCE2_CODE varchar(255), REFERENCE3_CODE varchar(255), primary key (TRANSACTION_NO))
14:30:31,781 DEBUG SchemaExport:296 - alter table CHILD1 add constraint FK766DA2B5FA892A59 foreign key (TRANSACTION_NO) references TRANSACTIONS
14:30:31,781 DEBUG SchemaExport:296 - alter table CHILD2 add constraint FK766DA2B6FA892A59 foreign key (TRANSACTION_NO) references TRANSACTIONS
14:30:31,781 DEBUG SchemaExport:296 - alter table CHILD3 add constraint FK766DA2B7FA892A59 foreign key (TRANSACTION_NO) references TRANSACTIONS
14:30:31,781 DEBUG SchemaExport:296 - alter table TRANSACTIONS add constraint FKFE9871555CED4E25 foreign key (REFERENCE3_CODE) references REFERENCE3
14:30:31,781 DEBUG SchemaExport:296 - alter table TRANSACTIONS add constraint FKFE9871555B387585 foreign key (REFERENCE2_CODE) references REFERENCE2
14:30:31,781 DEBUG SchemaExport:296 - alter table TRANSACTIONS add constraint FKFE98715559839CE5 foreign key (REFERENCE1_CODE) references REFERENCE1
14:30:31,796 INFO SchemaExport:202 - schema export complete
14:30:31,968 ERROR BasicPropertyAccessor:167 - IllegalArgumentException in class: transactions.Reference1, getter method of property: ref1_code


Name and version of the database you are using: hsqldb.jar

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

14:30:29,828 INFO Environment:479 - Hibernate 3.1.2
14:30:29,843 INFO Environment:509 - hibernate.properties not found
14:30:29,843 INFO Environment:525 - using CGLIB reflection optimizer
14:30:29,843 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
14:30:29,953 INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
14:30:29,953 INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
14:30:30,359 INFO Configuration:469 - Reading mappings from resource: transactions/TransactionElement.hbm.xml
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of transactions.Reference1.ref1_code
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.engine.ForeignKeys$Nullifier.isNullifiable(ForeignKeys.java:137)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:69)
at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:47)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:263)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:114)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:559)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:543)
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.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.save(Unknown Source)
at transactions.TransactionManager.createAndStoreTransaction(TransactionManager.java:184)
at transactions.TransactionManager.main(TransactionManager.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)
... 26 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 3:26 am 
Beginner
Beginner

Joined: Wed Apr 05, 2006 3:19 pm
Posts: 43
You seem to have an illegal (or even NO) getter method for "ref1_code" specified in this mapping:

Code:
<class name="transactions.Reference1" table="REFERENCE1">
<id name="ref1_code" column="REFERENCE1_CODE">
<generator class="assigned"/>
</id>
<property name="ref_desc" column="REFERENCE_DESCRIPTION"/>
...

_________________
Don't forget to rate my post if it helped. :)


Top
 Profile  
 
 Post subject: uhm..
PostPosted: Thu Apr 27, 2006 3:50 am 
Newbie

Joined: Thu Apr 27, 2006 2:46 am
Posts: 2
Uhm.. I did not even use the Reference1 class yet.. and I did not use any of the methods or called any method under the Reference1 class. I just wanted to insert aTransaction into the database.. Do you think the problem has to do with the association between TransactionElement class and Reference1 class? How can I solve this problem? thanks... I've been trying to solve this for hours... *newbie*


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:08 am 
Beginner
Beginner

Joined: Fri Apr 09, 2004 12:47 pm
Posts: 36
From the stack trace, it seems Hibernate is calling the getter and receives a IllegalArgumentException. It this happens, that's because an instance of Reference1 is somehow attached to the session, either directly or indirectly (e.g. you saved something that refers Reference1 and has a cascading save).


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.