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