• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass more than one parameter to the session.load()

 
Bushra Binte
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,m trying to pass more than one parameter to session.load().


Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
String res = (String)session.load(LoginDTO.class,loginProps);

and loginProps contain userName and pwd Strings.

Login.hbm.xml:
------------------

<hibernate-mapping>
<class dynamic-insert="false" dynamic-update="false" mutable="true"
table="logindtls" name="com.spring.hib.dto.LoginDTO" optimistic-lock="version"
polymorphism="implicit" select-before-update="false">
<id column="username" name="userName"/>
<property column="pwd" name="pwd"/>
</class>
</hibernate-mapping>

there is something wrong in my mapping file Login.hbm.xml.Could anyone please help.
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<id column="username" name="userName"/>


Here, only the userName is the primary key.

If you want to pass both userName and password (to validate login maybe), you will have to create a composite key out of them on the table.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic