-->
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.  [ 5 posts ] 
Author Message
 Post subject: serializable problem with session.get(...)
PostPosted: Tue Nov 14, 2006 9:46 am 
Regular
Regular

Joined: Mon Jul 31, 2006 4:59 pm
Posts: 53
Hibernate version: 3.2

I am trying this code:

Code:

MyClass mc = null;
long id=1;

try {
   if (lock) {
       mc = (MyClass) session.get(MyClass.class, id,LockMode.UPGRADE);
   }
   else {
       mc = (MyClass) session.get(MyClass.class, id);
   }
}


It does not work, i have the error that the parameters are wrong. Eclipse need: "Class, Serializable, Lockmode".

Any idea whats wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 9:48 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Get ready to slap your forehead. :)

long is not Serializable.
Long is Serializable.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 10:07 am 
Regular
Regular

Joined: Mon Jul 31, 2006 4:59 pm
Posts: 53
Oh holy sh** !! *slapshimself*

thanx for the hint!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 12:10 pm 
Beginner
Beginner

Joined: Sat Oct 04, 2003 7:00 am
Posts: 26
Location: Roma,IT
In java 5 this code is valid? because autowrapper function or i say wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 14, 2006 12:14 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Java5 should autobox the primitive long to a Long.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.