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.  [ 1 post ] 
Author Message
 Post subject: entity's collection: SQL Alias problem
PostPosted: Mon Sep 03, 2007 12:28 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 1:25 pm
Posts: 26
Location: Recife, PE, Brazil
Imagine you have a Entity called as "Person".

That business class has 5 properties. One of them is the primary key: ID, int, not null

There is a property called "Reports". Its data is constructed by a relationship with two other tables.

On the business rule has as necessity a collections List with several records of Person class. A very possible result would be the following:

(Here is showed just 3 Person's properties)

ID | Reports | Date
1 | 20 | 04-01-2007
3 | 10 | 04-25-2007
1 | 30 | 04-6-2007
1 | 20 | 04-15-2007
3 | 10 | 04-10-2007
6 | 10 | 04-08-2007



as you can see...there are three times the ID 1, and twice ID 3.

How does NHibernate get that result?

The steps would be something like that:

1. Gets object's ID with value 1 => put it in the Session;
2. Gets object's ID with value 3 => put it in the Session;
3. Gets object's ID with value 1 ? it already is in the Session, Use it;
4. Gets object's ID with value 1 ? it already is in the Session, Use it;
5. Gets object's ID with value 3 ? it already is in the Session, Use it;
6. Gets object's ID with value 6 => put it in the Session;

for ids 1 and 3..their records are different..

But as NHibernate's logic firstly looks for it in the Session...the records always will be the same, even thought the DataAdapter has records that aren't the same.

Reports and Date are aliases from other columns.

How to avoid that?


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

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.