• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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

 
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.
 
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.
 
It runs on an internal combustion engine. This ad does not:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!