I changed from a single primary key to a composite one and now I get the three
rows I'm expecting:
<composite-id>
<key-property column="CCR_ID" length="22" name="id" type="long"/>
<key-property column="FORM_ID" length="22" name="formId" type="long"/>
<key-property column="SHEET_ID" length="22" name="sheetId" type="long"/>
</composite-id>
<!--id
name="id"
column="ccr_id"
unsaved-value="null"
>
<generator class="sequence">
</generator>
</id-->
I'm using XDoclet to generate my mapping file, and I've found a few issues
with generating the <composite-id> element, so I guess I'll take my
generated-then-edited mapping file and put it back in my source tree.
XDoclet supposedly supports the composite-id element now, but from the
samples, it looks like you need a class to represent the composite-id.
Secondly, it uses the hibernate-mapping.dtd, where the above XML requires
hibernate-mapping-1.1.dtd.
Matt
> I'm guessing this might be b/c I have a single primary key defined in my
> mapping file, and there are actually multiple records in this table with
> that primary key.
>
> Thanks,
>
> Matt
>
> -----Original Message-----
> From: Raible, Matt
> Sent: Tuesday, January 14, 2003 12:33 PM
> To: '[EMAIL PROTECTED]'
> Subject: Query only brings back first record
>
> I have the following hibernate code that queries a table and brings back
> rows. Hibernate brings back the proper number of rows (3), but each object
> (row) is identical - the first one.
>
> StringBuffer query = new StringBuffer();
> query.append("from cr in class
> com.comcast.cable.dmc.itd.cct.persistence.ChangeRequestDetail ");
> query.append("where (cr.msoId=? and cr.headendId=?) ");
> query.append("or (cr.msoId=0) or (cr.headendId=0) ");
> query.append("order by cr.msoName");
> ses = HibernateSession.currentSession();
>
> // create arrays of variables to bind and types
> Object[] vars = new Object[] { msoId, headendId };
> Type[] types = new Type[] { Hibernate.LONG, Hibernate.LONG };
>
> crList = (List) ses.find(query.toString(), vars, types);
>
>
> When I run this query in Oracle's sqlplus, I get 3 unique rows:
>
> MSO_DESC HEADEND_NAME FORM_DESC
> ------------------------------ ------------------------------
> ----------------
> AT&T AMERICAN CANYON, CA HSCRF
> AT&T AMERICAN CANYON, CA CMCF
> AT&T AMERICAN CANYON, CA CMCF
>
> Here's the identical objects from my test:
>
> [junit] DEBUG [main]
> ChangeRequestDAOHibernateTest.testGetChangeRequests(81) | [com.comcast.cabl
> e.dmc.itd.cct.persistence.ChangeRequestDetail
> [junit] msoName=AT&T
> [junit] headendName=AMERICAN CANYON, CA
> [junit] crStatusId=160
> [junit] crStatus=Warning
> [junit] formId=700
> [junit] formName=HSCRF
> [junit] sheetId=800
> [junit] sheetName=HSCRF_SIGNAL
> [junit] statusId=160
> [junit] status=Warning
> [junit] , com.comcast.cable.dmc.itd.cct.persistence.ChangeRequestDetail
> [junit] msoName=AT&T
> [junit] headendName=AMERICAN CANYON, CA
> [junit] crStatusId=160
> [junit] crStatus=Warning
> [junit] formId=700
> [junit] formName=HSCRF
> [junit] sheetId=800
> [junit] sheetName=HSCRF_SIGNAL
> [junit] statusId=160
> [junit] status=Warning
> [junit] , com.comcast.cable.dmc.itd.cct.persistence.ChangeRequestDetail
> [junit] msoName=AT&T
> [junit] headendName=AMERICAN CANYON, CA
> [junit] crStatusId=160
> [junit] crStatus=Warning
> [junit] formId=700
> [junit] formName=HSCRF
> [junit] sheetId=800
> [junit] sheetName=HSCRF_SIGNAL
> [junit] statusId=160
> [junit] status=Warning
> [junit] ]
>
> Thanks,
>
> Matt
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: Take your first step towards giving
> your online business a competitive advantage. Test-drive a Thawte SSL
> certificate - our easy online guide will show you how. Click here to get
> started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
> _______________________________________________
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
-- Matt Raible, Raible Designs, Morrison CO US
-- Tel: +1 303 979-5340
-- Mob: +1 720 560-8460
-- Fax: +1 508 256-6471
-- Web: http://www.raibledesigns.com
-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving
your online business a competitive advantage. Test-drive a Thawte SSL
certificate - our easy online guide will show you how. Click here to get
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel