-->
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: Caused by: java.lang.IllegalArgumentException
PostPosted: Mon Mar 27, 2006 5:26 pm 
Beginner
Beginner

Joined: Mon Mar 27, 2006 3:44 pm
Posts: 26
I am relatively new to hibernate. I am evaluating hibernate as O/R tool for my company. I have a legacy database and I am trying out a simple load operation using composite key. I have a primary class created by middle gen
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>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.sungard.octagon.maintenance.Dictionary"
table="dictionary"
>

<composite-id name="comp_id" class="com.sungard.octagon.maintenance.Dictiona
ryPK">
<key-property
name="DictCode"
column="dict_code"
type="java.lang.String"
length="12"
/>
<key-property
name="SubCode"
column="sub_code"
type="java.lang.String"
length="12"
/>
</composite-id>

<property
name="codeDesc"
type="java.lang.String"
column="code_desc"
not-null="true"
length="30"
/>
<property
name="subDesc"
type="java.lang.String"
column="sub_desc"
not-null="true"
length="30"
/>
<property
name="updateUser"
type="java.lang.String"
column="update_user"
not-null="true"
length="12"
/>
<property
name="updateDate"
type="java.sql.Date"
column="update_date"
not-null="true"
length="26"
/>

<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->


</class>
</hibernate-mapping>

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

dictPk = new DictionaryPK();
System.out.println("After PK1");
dictPk.setDictCode(dictCode);
System.out.println("After setDictCode"+ dictCode);
dictPk.setSubCode(subCode);
System.out.println("After setSubCode"+ subCode);
Dictionary dict = new Dictionary();
System.out.println("After dict init");
dict.setComp_id(dictPk);
System.out.println("After setComp_id dictcode="+ dict.ge
tComp_id().getDictCode());
//dictData = (Dictionary) session.load(Dictionary.class,
dictPk);
dictData = (Dictionary) session.load(Dictionary.class,di
ct);
Full stack trace of any exception that occurs:
After session open---|#]

[#|2006-03-27T15:15:40.710-0600|SEVERE|sun-appserver-pe8.1_01|org.hibernate.prop
erty.BasicPropertyAccessor|_ThreadID=29;|IllegalArgumentException in class: com.
sungard.octagon.maintenance.DictionaryPK, getter method of property: DictCode|#]

[#|2006-03-27T15:15:40.713-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=29;|
Property Access Exception in class: class com.sungard.octagon.maintenance.Dictio
naryPK|#]

[#|2006-03-27T15:15:40.714-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=29;|
Property Access Exception in property: DictCode|#]

[#|2006-03-27T15:15:40.714-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=29;|
Property Access Exception in class: IllegalArgumentException occurred calling ge
tter of com.sungard.octagon.maintenance.DictionaryPK.DictCode|#]

[#|2006-03-27T15:15:40.718-0600|WARNING|sun-appserver-pe8.1_01|javax.enterprise.
system.stream.err|_ThreadID=29;|org.hibernate.PropertyAccessException: IllegalAr
gumentException occurred calling getter of com.sungard.octagon.maintenance.Dicti
onaryPK.DictCode
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPro
pertyAccessor.java:171)
at org.hibernate.tuple.AbstractComponentTuplizer.getPropertyValue(Abstra
ctComponentTuplizer.java:121)
at org.hibernate.tuple.AbstractComponentTuplizer.getPropertyValues(Abstr
actComponentTuplizer.java:133)
at org.hibernate.tuple.PojoComponentTuplizer.getPropertyValues(PojoCompo
nentTuplizer.java:88)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java
:307)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:158)
at org.hibernate.engine.EntityKey.getHashCode(EntityKey.java:69)
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:42)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEv
entListener.java:76)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869)
Name and version of the database you are using:
Ingres 2.6

The generated SQL (show_sql=true):
Nothing generated
Debug level Hibernate log excerpt:

I have tested the connectivity to the database using other simple hibernate tests and they worked fine
The java files are as follows
package com.sungard.octagon.maintenance;
// Generated Mar 22, 2006 1:45:36 PM by Hibernate Tools 3.1.0 beta3

import java.sql.Timestamp;


/**
* Dictionary generated by hbm2java
*/

public class Dictionary implements java.io.Serializable {


// Fields

private DictionaryPK comp_id;
private String codeDesc;
private String subDesc;
private String updateUser;
private Timestamp updateDate;


// Constructors

/** default constructor */
public Dictionary() {
}


/** full constructor */
public Dictionary(DictionaryPK comp_id, String codeDesc, String subDesc, Str
ing updateUser, Timestamp updateDate) {
this.comp_id = comp_id;
this.codeDesc = codeDesc;
this.subDesc = subDesc;
this.updateUser = updateUser;
this.updateDate = updateDate;
}



// Property accessors

public DictionaryPK getComp_id() {
return this.comp_id;
}

public void setComp_id(DictionaryPK comp_id) {
this.comp_id = comp_id;
}

public String getDictCode() {
return this.comp_id.getDictCode();
}

public void setDictCode(String dictCode) {
this.comp_id.setDictCode(dictCode);
}

public String getSubCode() {
return this.comp_id.getSubCode();
}

public void setSubCode(String subCode) {
this.comp_id.setSubCode(subCode);
}
public String getCodeDesc() {
return this.codeDesc;
}

public void setCodeDesc(String codeDesc) {
this.codeDesc = codeDesc;
}

public String getSubDesc() {
return this.subDesc;
}

public void setSubDesc(String subDesc) {
this.subDesc = subDesc;
}

public String getUpdateUser() {
return this.updateUser;
}

public void setUpdateUser(String updateUser) {
this.updateUser = updateUser;
}

public Timestamp getUpdateDate() {
return this.updateDate;
}

public void setUpdateDate(Timestamp updateDate) {
this.updateDate = updateDate;
}

package com.sungard.octagon.maintenance;
// Generated Mar 22, 2006 1:45:38 PM by Hibernate Tools 3.1.0 beta3



/**
* DictionaryPK generated by hbm2java
*/

public class DictionaryPK implements java.io.Serializable {


// Fields

private String DictCode;
private String SubCode;


// Constructors

/** default constructor */
public DictionaryPK() {
}


/** full constructor */
public DictionaryPK(String dictCode, String subCode) {
System.out.println("In DictionaryPK");
this.DictCode = dictCode;
this.SubCode = subCode;
System.out.println("After DictionaryPK");
}



// Property accessors

public String getDictCode() {
return this.DictCode;
}

public void setDictCode(String dictCode) {
this.DictCode = dictCode;
}

public String getSubCode() {
return this.SubCode;
}

public void setSubCode(String subCode) {
this.SubCode = subCode;
}
public boolean equals(Object other) {
if(this == other)
return true;
if ( !(other instanceof DictionaryPK) ) return false;
DictionaryPK castOther = (DictionaryPK) other;
if(this.getDictCode().equals(castOther.getDictCode()) &&
this.getSubCode().equals(castOther.getSubCode()))
return true;
return false;
}

public int hashCode() {
return (getDictCode() + getSubCode())
.hashCode();
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 6:27 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
try removing the 'type="java.util.String"' from your key-property all-together - it will pickup based on reflection and it smells like a reflection problem.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 11:27 am 
Beginner
Beginner

Joined: Mon Mar 27, 2006 3:44 pm
Posts: 26
I changed the mapping file and it did not help. I get the same exception. The following code works fine
Criteria criteria = session.createCriteria(Dictionary.cl
ass);
criteria.add(Expression.eq("comp_id.DictCode", dictCode)
);
criteria.add(Expression.eq("comp_id.SubCode", subCode));

dictData = (Dictionary)criteria.uniqueResult();

The problem here is it does not use my cache as it does not use load method to query the object


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 12:06 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
what does that have to do with: IllegalArgumentException ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 12:39 pm 
Beginner
Beginner

Joined: Mon Mar 27, 2006 3:44 pm
Posts: 26
The original code I posted gave the illegalargumentexception. The code using criteria works fine but does not reuse data from cache even if is available. I have tried the following code too

Criteria criteria = session.createCriteria(Dictionary.class);
dictPk = new DictionaryPK(dictCode,subCode);
criteria.add(Expression.idEq(dictPk));
It gets it from the database


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 3:11 pm 
Beginner
Beginner

Joined: Mon Mar 27, 2006 3:44 pm
Posts: 26
Trying to fix this without any luck
I have the following code now
dictPk = new DictionaryPK(dictCode,subCode);
dictData = (Dictionary) session.load(Dictionary.class,dictPk);
The values are already availeble in the secondary cache
I get the following exception after it seems to have located and loaded the value from the cache
[#|2006-03-29T13:03:55.783-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=13;|
13:03:55,782 DEBUG DefaultLoadEventListener:153 - loading entity: [com.sungard.o
ctagon.maintenance.Dictionary#component[DictCode,SubCode]{DictCode=ACCT_TYPE, Su
bCode=A}]
|#]

[#|2006-03-29T13:03:55.784-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=13;|13:03:55,783 DEBUG DefaultLoadEventListener:230 - c
reating new proxy for entity
|#]

[#|2006-03-29T13:03:55.785-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=13;|13:03:55,784 DEBUG JDBCContext:225 - after autocomm
it
|#]

[#|2006-03-29T13:03:55.786-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=13;|13:03:55,785 DEBUG ConnectionManager:296 - aggressi
vely releasing JDBC connection
|#]

[#|2006-03-29T13:03:55.787-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.stream.out|_ThreadID=13;|13:03:55,786 DEBUG SessionImpl:434 - after transact
ion completion
|#]

[#|2006-03-29T13:03:55.788-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.container.ejb|_ThreadID=13;|EJB5018: An exception was thrown during an ejb i
nvocation on [DictionaryBean]|#]

[#|2006-03-29T13:03:55.788-0600|INFO|sun-appserver-pe8.1_01|javax.enterprise.sys
tem.container.ejb|_ThreadID=13;|
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseConta
iner.java:2807)
at com.sun.ejb.containers.BaseContainer.checkExceptionNoTx(BaseContainer
.java:2647)
at com.sun.ejb.containers.BaseContainer.checkExceptionBeanMgTx(BaseConta
iner.java:2585)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:
2485)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:81
9)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInv
ocationHandler.java:137)
at $Proxy29.getRow(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(Reflecti
veTie.java:123)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
tchToServant(CorbaServerRequestDispatcherImpl.java:648)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispa
tch(CorbaServerRequestDispatcherImpl.java:192)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
Request(CorbaMessageMediatorImpl.java:1709)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
(CorbaMessageMediatorImpl.java:1569)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(C
orbaMessageMediatorImpl.java:951)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.call
back(RequestMessage_1_2.java:181)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest
(CorbaMessageMediatorImpl.java:721)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatc
h(SocketOrChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(
SocketOrChannelConnectionImpl.java:1262)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.
run(ThreadPoolImpl.java:409)
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntity
Tuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(Ab
stractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessa
ry(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultL
oadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEv
entListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:781)
at com.sungard.octagon.maintenance.DictionaryBean.getRow(DictionaryBean.
java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivil
eged(EJBSecurityManager.java:950)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158
)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInv
ocationHandler.java:128)
... 16 more
|#]
Any help is welcome


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.