-->
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: Get object from previously retrieved DataRow
PostPosted: Sun Jan 14, 2007 9:10 pm 
Newbie

Joined: Sun Jan 14, 2007 8:48 pm
Posts: 2
Hi there

I just started with NHibernate which runs just great out of the box. However, I was hoping to apply a somewhat mixed strategy: For maintenance, my users will have to work with large amounts of tabular data only (editing grids): In this case, I want to apply direct data binding to relational data. However, for everything else, I'd rather work with objects. My use case looks like this:

1: System binds data to grid and shows table
2: If needed, user selects row and requests some advanced functionality
3: System transforms data of selected row into a business object for further processing (without running another query against the DB).

In other words: I'd like to access NH's mapping engine directly in order to just perform the mapping without accessing the database again. I've applied this technique pretty often with my old ORM tool, so I hope I just overlooked it. Any idea?

Thanks for your advice
Philipp


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 2:47 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
You can use session.Lock() to associate an entity with a session.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 15, 2007 6:02 am 
Newbie

Joined: Sun Jan 14, 2007 8:48 pm
Posts: 2
Ayende Rahien wrote:
You can use session.Lock() to associate an entity with a session.


Thanks for the fast reply! However, I don't see how to solve my problem that way - I don't even have an object yet (do I have to create an empty dummy instance?). Imagine the following snippet:

Code:
public MyBusinessObject TransformRow(DataRow row)
{
  ISession session = GetSession();
  MyBusinessObject obj;
 
  //TODO create object based on row
  [GREAT CODE GOES HERE...]


  //finally return the object
  return obj
}


Thanks in advance :)

Philipp


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.