-->
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.  [ 5 posts ] 
Author Message
 Post subject: Custom SQL for create, update and delete
PostPosted: Wed Nov 17, 2010 8:23 am 
Newbie

Joined: Tue Nov 16, 2010 9:43 am
Posts: 19
<class name="Person">
<id name="id">
<generator class="increment"/>
</id>
<property name="name" not-null="true"/>
<sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>
<sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>
<sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>
</class>



[b] how to call above queries in client application


Top
 Profile  
 
 Post subject: Re: Custom SQL for create, update and delete
PostPosted: Wed Nov 17, 2010 11:02 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Call "save", "update" or "delete" on your Session object. Sounds like obvious thing to me :O


Top
 Profile  
 
 Post subject: Re: Custom SQL for create, update and delete
PostPosted: Thu Nov 18, 2010 2:02 am 
Regular
Regular

Joined: Fri Nov 12, 2010 4:13 am
Posts: 81
Location: India
session.save(Person) - For save
session.update(Person) - For update
session.delete(Person) - For delete

_________________
Thanks & Regards,
Chirag


Top
 Profile  
 
 Post subject: Re: Custom SQL for create, update and delete
PostPosted: Thu Nov 18, 2010 7:13 am 
Newbie

Joined: Tue Nov 16, 2010 9:43 am
Posts: 19
ok, but how to pass values in the placeholders ie (?) from client application


Top
 Profile  
 
 Post subject: Re: Custom SQL for create, update and delete
PostPosted: Fri Nov 19, 2010 9:44 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Set them in your Person object using field setters.

Code:
person.setName("sameeulla")
session.save(person)


But better read the manual first. Your questions are extremely trivial. You won't be able to program successfully without at least some basic understanding how Java and database mappings work.


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

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.