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: IllegalArgumentException calling getter of a mapped class
PostPosted: Mon Aug 09, 2004 10:48 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 9:01 pm
Posts: 21
Hibernate version:
2.0.3


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

<hibernate-mapping>

<class name="com.aol.ic.art.data.domain.Request" table="REQUEST">
<id name="id" column="ID">
<generator class="native"/>
</id>

<property name="requestorDn">
<column name="REQUESTORDN" length="255" not-null="true"/>
</property>
<property name="customerDn">
<column name="CUSTOMERDN" length="255" not-null="true"/>
</property>

<property name="fulfillmentBuildingDn">
<column name="FULFILLMENTBUILDINGDN" length="255" not-null="true"/>
</property>

<property name="fulfillmentRoomNumber">
<column name="FULFILLMENTROOMNUMBER" length="20" not-null="true"/>
</property>

<property name="lastApproverDn">
<column name="LASTAPPROVERDN" length="255" not-null="true"/>
</property>

<property name="nextApproverRoleDn">
<column name="NEXTAPPROVERROLEDN" length="255" not-null="true"/>
</property>

<property name="ticketNumber">
<column name="TICKETNUMBER" length="30" not-null="true"/>
</property>

<property name="type">
<column name="TYPE" length="30" not-null="true"/>
</property>

<property name="comments">
<column name="COMMENTS" length="255" not-null="true"/>
</property>

<set name="products" table="REQUEST_PRODUCT_LINK" inverse="true" lazy="true">
<key column="REQUESTID"/>
<many-to-many class="com.aol.ic.art.data.domain.Product"/>
</set>

<set name="states" inverse="true" lazy="true">
<key column="REQUESTID"/>
<one-to-many class="com.aol.ic.art.data.domain.RequestStatus"/>
</set>
</class>
</hibernate-mapping>

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

public static void testCreate() throws ARTException{
Set productSet = new HashSet();
productSet.add(new Long(1));
productSet.add(new Long(2));
productSet.add(new Long(3));

Set stateSet = new HashSet();
stateSet.add(new Long(2));
productSet.add(new Long(3));
productSet.add(new Long(3));


logger.info("Before Request Creation");
// 1. Build a Request
Request r = new Request("requestorDn", "customerDn", "comments",
"lastApproverDn", "fulfillmentBuildingDn",
"200200", "nextApproverRoleDn",
"ticketNumber", stateSet, productSet,"SOFTWARE");

logger.info("After Request Creation");
Transaction tx = null;
try {
//3. Open a session
Session session = HibernateUtil.currentSession();

// 4. Save Request and close Session

tx = session.beginTransaction();
session.save(r);
logger.info("After Request Save");
tx.commit();
logger.info("After Transaction Commit");
}
catch (HibernateException he) {
if (tx!=null)
try {
logger.info("In Catch block before rollback");
tx.rollback();
logger.info("In Catch block after rollback");
} catch (HibernateException e) {
e.printStackTrace();
}
throw new ARTException(he.getMessage(), ARTError.ARTDB_ERROR);
}
finally {
logger.info("In Finally block");
try {
HibernateUtil.closeSession();
} catch (HibernateException e) {
e.printStackTrace();
}
}


Full stack trace of any exception that occurs:

Log provided below

Name and version of the database you are using:
Oracle 9.2.0


Debug level Hibernate log excerpt:
2004-08-09 10:21:20 DEBUG SessionImpl.saveWithGeneratedIdentifier(778) - generated identifier: 7
2004-08-09 10:21:20 DEBUG SessionImpl.doSave(825) - saving [com.aol.ic.art.data.domain.Request#7]
2004-08-09 10:21:20 DEBUG WrapVisitor.processArrayOrNewCollection(81) - Wrapped
collection in role: com.aol.ic.art.data.domain.Request.products
2004-08-09 10:21:20 DEBUG WrapVisitor.processArrayOrNewCollection(81) - Wrapped
collection in role: com.aol.ic.art.data.domain.Request.states
2004-08-09 10:21:20 INFO TestHibernateUtil.testCreate(?) - After Request Save
2004-08-09 10:21:20 DEBUG JDBCTransaction.commit(59) - commit
2004-08-09 10:21:20 DEBUG SessionImpl.flushEverything(2242) - flushing session
2004-08-09 10:21:20 DEBUG SessionImpl.flushEntities(2435) - Flushing entities and processing referenced collections
2004-08-09 10:21:20 DEBUG SessionImpl.updateReachableCollection(2880) - Collection found: [com.aol.ic.art.data.domain.Request.products#7], was: [<unreferenced>]
2004-08-09 10:21:20 DEBUG SessionImpl.updateReachableCollection(2880) - Collection found: [com.aol.ic.art.data.domain.Request.states#7], was: [<unreferenced>]
2004-08-09 10:21:20 DEBUG SessionImpl.flushCollections(2776) - Processing unreferenced collections
2004-08-09 10:21:20 DEBUG SessionImpl.flushCollections(2790) - Scheduling collection removes/(re)creates/updates
2004-08-09 10:21:20 DEBUG SessionImpl.flushEverything(2266) - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2004-08-09 10:21:20 DEBUG SessionImpl.flushEverything(2271) - Flushed: 2 (re)creations, 0 updates, 0 removals to 2 collections
2004-08-09 10:21:20 DEBUG Printer.toString(75) - listing entities:
2004-08-09 10:21:20 ERROR BasicPropertyAccessor$BasicGetter.get(106) - IllegalArgumentException in class: com.aol.ic.art.data.domain.Product, getter method of property: id
2004-08-09 10:21:20 INFO TestHibernateUtil.testCreate(?) - In Catch block before rollback
2004-08-09 10:21:20 DEBUG JDBCTransaction.rollback(82) - rollback
2004-08-09 10:21:20 DEBUG SessionImpl.afterTransactionCompletion(585) - transaction completion
2004-08-09 10:21:20 INFO TestHibernateUtil.testCreate(?) - In Catch block after rollback
2004-08-09 10:21:20 INFO TestHibernateUtil.testCreate(?) - In Finally block
2004-08-09 10:21:20 FATAL ARTInitServlet.init(?) - Init ART - In catch block: IllegalArgumentException occurred calling getter of com.aol.ic.art.data.domain.Product.id


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 12:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
If your going to post code and/or mappings please use the code markup. That way we do not have to sit here and interpret where all the indents should be.

The set named "products" is defined to be of type com.aol.ic.art.data.domain.Product, and yet you populate the set with Longs. How can that possibly work?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 1:07 pm 
Beginner
Beginner

Joined: Wed Aug 04, 2004 9:01 pm
Posts: 21
According to you, the one-to-many mapping between two persistent classes can happen either at the class level or at the hibernate mapping level.

If the above statement is true, what are the tradeoffs?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 09, 2004 1:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I suggest you re-read some documentation and tutorials.


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.