-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Query Language
PostPosted: Thu Jan 25, 2007 6:46 am 
Newbie

Joined: Tue Jan 16, 2007 7:54 am
Posts: 6
Hi Friends,

I have a SQL something like this:-
Code:
stmt = conn.prepareStatement("SELECT old_stories.id, "
            + "old_stories.title, "
            + "old_stories.body, old_stories.date, "
            + "users.nickname FROM old_stories, users"
            + " WHERE old_stories.id=" + storyId
            + " AND old_stories.writer=users.id");

I want to write an equivalent Query in hibernate. Is it possible to do so.

My stories hbm xml is -

Code:
<class name="com.hp.ts.story.bean.Stories" table="stories">
       <id name="id" column="ID">
            <generator class="native"/>
        </id>
        <property name="title" type="string" column="title"/>
        <property name="body" type="string" column="body"/>
        <property name="date" type="timestamp" column="date"/>
        <property name="writer" type="integer" column="writer"/>   
        <property name="category" type="integer" column="category"/>
   </class>

How can I incorporate the SQL logic into my hibernate?

Please help.

Thanks!
Vishal



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 6:16 am 
Newbie

Joined: Tue Jan 16, 2007 7:54 am
Posts: 6
Is there nobody who can help me on this?

Vishal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:03 am 
Newbie

Joined: Tue Nov 28, 2006 3:24 am
Posts: 11
Hi,

it is possible check
http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html

for more information.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.