Hi Every One,
I have a doubt about session.get() method.we have different overloaded methods with this name.Like..
public Object get(Class clazz,Serializable id)throws HibernateException
and
public Object get(String entityName,Serializable id)throws HibernateException
In the signature of above methods..
1. what is id ? Is it the Primary key in our table?
2. what is entityName in the second method ?
I have a table Event with columns
eventId,eventTitle and eventLead.eventId is primary key.
I tried to retrieve data from table depends on eventId value like below..
Code:
int eventId=4;
Event event=(Event)session.get(Event.class,eventId);
This works fine for me.
But when i tried to retrive data depends on eventTitle value like below..
Code:
String eventTitle="Parents meeting";
Event event=(Event)session.get(Event.class,eventTitle);
But this time i got an exception like....
Code:
Exception in thread "main" org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Integer, got class java.lang.String
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:86)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at client.EventManager.retriveEvent(EventManager.java:32)
at client.TestClient.main(TestClient.java:29)
Please can anybody tell me,how to write code for retrieving all the records related to a particular eventTitle.
Thank q very much.
sirisha.