-->
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.  [ 10 posts ] 
Author Message
 Post subject: Newbie question about CreateCriteria
PostPosted: Thu Jul 21, 2005 9:45 am 
Newbie

Joined: Thu Jul 21, 2005 9:19 am
Posts: 3
Hi!

I'm a new NHibernate's user and I'm very excited with its features!
Well, as a new user, I was reading the NHibernate and Hibernate's documentation. I read on Hibernate's v3 documentation about a feature called: SetProjection that is used in group with CreateCriteria.
I'm not sure, but I think that the NHibernat's current version doesn't implement some Hibernate's v3 features.

Well, my question is:

Is there a way to retrieve just used columns and avoid unnecessary column, using the NHibernate's current version ?
I'm asking it, because sometimes u don't need to retrieve all columns from table.

Best Regards!
Thiago A. Flessak


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 23, 2005 1:52 pm 
Newbie

Joined: Thu Jul 21, 2005 9:19 am
Posts: 3
Hi mates!

I really didn't find nothing about this subject. :(

Is there no way to retrieve just some fields from table to populate the mapped object ?

Can NHibernate populate just wanted fields and set "null" to others ?

Thank you!
Regards
Thiago A. Flessak


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 23, 2005 7:39 pm 
Newbie

Joined: Tue Jul 19, 2005 4:15 pm
Posts: 4
Location: Utah, USA
I hope I'm answering the right question. Let's say you have a table:

Person
-----------
PersonId
FirstName
LastName
PhoneNumber
Address

If you wanted to map this without the phone number and address you would simply do the following:
Code:
<class name="Person" table="Person">
     <id column="PersonId"... />
     <property name="FirstName" column="FirstName" type="string" />
     <property name="LastName" column="LastName" type="string" />
</class>

That's it. If you don't want to map the properties PhoneNumber and Address, you just don't map them. Don't put the corresponding <property> tags in the class definition.
I hope that's what you were looking for :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 4:40 pm 
Newbie

Joined: Thu Jul 21, 2005 9:19 am
Posts: 3
ttingey, thanx for your reply... but my question isn't related about mapping but populate mapped object just in wanted fields.

But ... I think that my question will be solved if the NHibernate's new version has "Projection" implementation. This link:

http://www.hibernate.org/hib_docs/v3/re ... projection

it's from Hibernate3's documentation. It explains about the "Projection" feature, and that's accurately what I want.

Best Regards
Thiago A. Flessak


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 7:34 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
Hibernate 3 is a massive rewrite that takes advantage of new Java5 features such as generics. NHibernate is working towards Hibernate 2.1 features. Once NH reaches 1.0 final, we may start looking at .Net 2.0 support, which lends itself to Hibernate 3 features. That's not to say that H3 features couldn't be implemented without .Net 2.0, but rather that H3 isn't really on the radar just yet. Reaching 1.0 is the current goal.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 4:26 pm 
Beginner
Beginner

Joined: Wed Jun 29, 2005 10:40 am
Posts: 30
Location: denver, co
The current NHibernate Criteria API is painfully far away from Hibernate3's. However, you can achieve what projections offer in straight hql.

To fetch only the properties of an object you want, just provide them in the select clause of your hql statement.

Example:
Code:
select user.FirstName, user.LastName from User user

will return an IList of object arrays, where the value at index 0 is the FirstName of a user and index 1 is the LastName.

You can also use this to select aggregate functions like count, max, min, avg.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 10:51 am 
Newbie

Joined: Wed Jan 25, 2006 3:42 pm
Posts: 5
Location: Tallahassee, FL
k-dub:

Have you fellows on the NHibernate team considered just jumping straight to C# 3.0 for your next major refactor? I'm sure you have been keeping up on it, and it's language features yield lots of power especially regarding the generics, and projections. For example, taking advantage of anonymous types in C# 3.0 would give a very clean way to project, as well as the cool lambda expressions for some pretty awesome criteria capablities. I suppose it depends on your time frame, and then when C# 3.0 becomes mature. A few nice advantages is that [1] it'd get you guys back on the front of .NET technology and [2] optimize NHibernate to work very efficiently in .NET.

As just as example of optimization, one could implement the composite pattern in .NET the classical way, building your own composite and leaf objects. But .NET already has the pattern built in (TreeView, TreeNode) and thus is sinceless to rewrite the pattern. Other examples are of course things like delegates, events and so forth to represent certain patterns. So leveraging all those .NET things of course just makes since. I only mention this because I see in the current versions of NH some things are just ported over as-is without refactoring to leverage .NET optimizations. But I think probably the more correct issue is that you guys are just trying to get it fully ported, before worrying about the optimizations.

Anyway, that is a concern that I just wanted to voice and I'm sure you guys all have thought/thinking of it. That aside, you guys rock! NHibernate is awesome and has really blown me away. I been watching you guys here in the forums and reading up, and you guys have been screaming wide open and doing an awesome job. k-dub, K-Pixel, and of course Sergy, and others I didn't mention ... great job! Wu, that sounds cliche. Errrr, I mean it. You dudes have been awesome, awesome, awesome. And I should really thank the Hibernate team too, for conceiving such a fantastic technolgy. All of you dudes are what REAL programmers are. Thanks a lot.

Timex

Timex


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 10:52 am 
Newbie

Joined: Wed Jan 25, 2006 3:42 pm
Posts: 5
Location: Tallahassee, FL
k-dub:

Have you fellows on the NHibernate team considered just jumping straight to C# 3.0 for your next major refactor? I'm sure you have been keeping up on it, and it's language features yield lots of power especially regarding the generics, and projections. For example, taking advantage of anonymous types in C# 3.0 would give a very clean way to project, as well as the cool lambda expressions for some pretty awesome criteria capablities. I suppose it depends on your time frame, and then when C# 3.0 becomes mature. A few nice advantages is that [1] it'd get you guys back on the front of .NET technology and [2] optimize NHibernate to work very efficiently in .NET.

As just as example of optimization, one could implement the composite pattern in .NET the classical way, building your own composite and leaf objects. But .NET already has the pattern built in (TreeView, TreeNode) and thus is sinceless to rewrite the pattern. Other examples are of course things like delegates, events and so forth to represent certain patterns. So leveraging all those .NET things of course just makes since. I only mention this because I see in the current versions of NH some things are just ported over as-is without refactoring to leverage .NET optimizations. But I think probably the more correct issue is that you guys are just trying to get it fully ported, before worrying about the optimizations.

Anyway, that is a concern that I just wanted to voice and I'm sure you guys all have thought/thinking of it. That aside, you guys rock! NHibernate is awesome and has really blown me away. I been watching you guys here in the forums and reading up, and you guys have been screaming wide open and doing an awesome job. k-dub, K-Pixel, and of course Sergy, and others I didn't mention ... great job! Wu, that sounds cliche. Errrr, I mean it. You dudes have been awesome, awesome, awesome. And I should really thank the Hibernate team too, for conceiving such a fantastic technolgy. All of you dudes are what REAL programmers are. Thanks a lot.

Timex

Timex


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 10:52 am 
Newbie

Joined: Wed Jan 25, 2006 3:42 pm
Posts: 5
Location: Tallahassee, FL
k-dub:

Have you fellows on the NHibernate team considered just jumping straight to C# 3.0 for your next major refactor? I'm sure you have been keeping up on it, and it's language features yield lots of power especially regarding the generics, and projections. For example, taking advantage of anonymous types in C# 3.0 would give a very clean way to project, as well as the cool lambda expressions for some pretty awesome criteria capablities. I suppose it depends on your time frame, and then when C# 3.0 becomes mature. A few nice advantages is that [1] it'd get you guys back on the front of .NET technology and [2] optimize NHibernate to work very efficiently in .NET.

As just as example of optimization, one could implement the composite pattern in .NET the classical way, building your own composite and leaf objects. But .NET already has the pattern built in (TreeView, TreeNode) and thus is sinceless to rewrite the pattern. Other examples are of course things like delegates, events and so forth to represent certain patterns. So leveraging all those .NET things of course just makes since. I only mention this because I see in the current versions of NH some things are just ported over as-is without refactoring to leverage .NET optimizations. But I think probably the more correct issue is that you guys are just trying to get it fully ported, before worrying about the optimizations.

Anyway, that is a concern that I just wanted to voice and I'm sure you guys all have thought/thinking of it. That aside, you guys rock! NHibernate is awesome and has really blown me away. I been watching you guys here in the forums and reading up, and you guys have been screaming wide open and doing an awesome job. k-dub, K-Pixel, and of course Sergy, and others I didn't mention ... great job! Wu, that sounds cliche. Errrr, I mean it. You dudes have been awesome, awesome, awesome. Thanks a lot.

Timex


Top
 Profile  
 
 Post subject: .NET Optimizations - Why not leap to C# 3.0 once matured?
PostPosted: Fri Apr 21, 2006 10:53 am 
Newbie

Joined: Wed Jan 25, 2006 3:42 pm
Posts: 5
Location: Tallahassee, FL
OPPS, posted twice by mistake. Site keeps timing out on me, so got posted twice during trying to reload. Sorry.

Timex


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.