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.  [ 1 post ] 
Author Message
 Post subject: Can i Retrieving a persistenc objects by String identifier..
PostPosted: Wed Apr 07, 2010 11:42 am 
Newbie

Joined: Wed Apr 07, 2010 11:22 am
Posts: 1
hi Guys
Cann't i Retrieve a persistence objects by String identifier..??

I tried the following example...
My persistence object is

Class Book{
String ISBN;
String bookName;
//
//
//All my setter and getter method
//
//
}

and Book.hbm.xml is

<hibernate-mapping>
<class name="Book" table="Book">
<id name="ISBN">
<generator class="assigned"/>
</id>
<property name="bookName"/>
</class>
</hibernate-mapping>


Now while i try to retrieve the Book Object using the following line

Book myBook = (Book) session.get(Book.class, ISBN); I am getting the following error

hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Integer, got class java.lang.String

Please Give me a solution...Cant i Retrieving a persistence objects by String identifier ??? or what can i do to retrieve my book object?


From
Utpal Dutta


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.