Author
hibernate mapping exception
raj baig
Ranch Hand
Joined: Jul 11, 2006
Posts: 96
posted Jul 15, 2006 01:03:00
0
hi, ref: to above: can't i have java beans with the same name may be in different packages to map a same table: like: <class name="sas.login.User" table="myuser1"> <id name="user_id" column="user_id"> <generator class="assigned"/> </id> <property name="account_id" column="account_id"/> <property name="uname" column="uname"/> <property name="pwd" column="pwd"/> </class> <class name="sas.hibernate.User" table="myuser1"> <id name="user_id" column="user_id"> <generator class="assigned"/> </id> <property name="account_id" column="account_id"/> <property name="uname" column="uname"/> <property name="pwd" column="pwd"/> </class> when i use different java bean names there is no problem. but when i use same javabean name in different packages also it throws Exception. how to resolve it.
Mark Spritzler
ranger
Sheriff
Joined: Feb 05, 2001
Posts: 16622
posted Jul 16, 2006 12:58:00
0
I think this is basically the same question that you are asking here. So I am going to close this duplicate post/thread. Please refrain from duplicate posting. Thanks Mark
Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
raj baig
Ranch Hand
Joined: Jul 11, 2006
Posts: 96
posted Jul 16, 2006 22:47:00
0
hi, this is the error i am getting: INFO - Mapping class: sas.login.User -> myuser1 DEBUG - Mapped property: user_id -> user_id DEBUG - Mapped property: account_id -> account_id DEBUG - Mapped property: uname -> uname DEBUG - Mapped property: pwd -> pwd error rg.hibernate.MappingException: Could not read mappings from resource: P erson.hbm.xml The code where i am accessing the hibernate is : Configuration conf=new Configuration(); conf.configure(); SessionFactory sf=conf.buildSessionFactory(); Session session=sf.openSession(); Query qry1=session.createQuery("from sas.login.User where account_id=?"); System.out.println("query created"); qry1.setInteger(0,101); List l1=qry1.list(); System.out.println("size: " +l1.size()); System.out.println("list created"); for(int i=0;i<l1.size();i++){ System.out.println("entered loop"); sas.login.User user1=(sas.login.User)l1.get(i); System.out.println("user obj created"); System.out.println(user1.getUser_id()); System.out.println(user1.getAccount_id()); System.out.println(user1.getUname()); System.out.println(user1.getPwd()); } Query qry2=session.createQuery("from saas.hibernate.User where account_id=?"); qry2.setInteger(0,102); List l2=qry2.list(); System.out.println("size: " +l2.size()); for(int i=0;i<l2.size();i++){ saas.hibernate.User user2=(saas.hibernate.User)l2.get(i); System.out.println(user2.getUname()); System.out.println(user2.getPwd()); }
subject: hibernate mapping exception