Hi,
I know the answer to this question is going to be very simple, but i've been so used to bringing back a single record into a map using either:
1. (User)query.uniqueResult() or
2. (User)session.load(User.class, userID)
type queries, that now that I want to return the contents of an entire table i'm lost. How do i say:
select * from table
and return the resultset?
In my code section below, I have written the code asI think it should be.
Hibernate version:
Jboss 4.0.0
Map
Code:
<class name="Artist" table="artisttbl">
<cache usage="read-write"/>
<id name="ID" column="artist_id">
<generator class="assigned"/>
</id>
<version name="Version" column="version" type="integer"/>
<property name="ArtistName" column="artist_name" type="string" not-null="true"/>
<property name="ArtistInfo" column="artist_info" type="string" not-null="true"/>
<property name="TrackLocation" column="track_location" type="string"/>
<property name="TrackInfo" column="track_info" type="string"/>
<property name="StockID" column="stock_id" type="string"/>
<set name="ArtistImages" inverse="true" lazy="true" cascade="all-delete-orphan">
<cache usage="read-write"/>
<key column="artist_id"/>
<one-to-many class="ArtistImages"/>
</set>
</class>
[class code]
Code:
InitialContext ctx = new InitialContext();
sessionfactory = (SessionFactory)ctx.lookup("java:/hibernate/SessionFactory");
session = sessionfactory.openSession();
transaction = session.beginTransaction();
//Get User details
query = session.createQuery("from test.Artist as artists");
artists = (Artist) query;
transaction.commit();
session.close();
Would calling this method as is in my java code enabe me to iterate through the entire recordset?
regards
Uzo