-->
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.  [ 5 posts ] 
Author Message
 Post subject: How to read only particular fields?
PostPosted: Mon Feb 13, 2006 3:36 pm 
Newbie

Joined: Fri Feb 10, 2006 4:44 pm
Posts: 2
Hi,

A few questions from a person trying to learn about NHibernate.

1)
Is it possible to read only some fields from a table?
For example - I have a table with many many fields. However, I want to display only a small subset in my search resutls screen. Is ti possible fro me to ask NHibernate to get only those fields? Otherwise I would be wasting a lot of resources.

2)
I use MyISAM tables in MySQL. I read one article which said that MyISAM should nto be used with NHibernate. I would like to keep using it though for much better speed. Is is possible to use it?

3)
What would be the best place to learn about HQL. i.e. learning about ways to access DB using NHIbernate?

many thanks !


Top
 Profile  
 
 Post subject: HQL
PostPosted: Tue Feb 14, 2006 12:08 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think if you just plan to read the data you could write a class and map it to the subset of column you want to read (you have to include the PK ofcourse). This way NHibernate will only select the mapped columns when loading the object. However you will not be able to update/insert as NHibernate does not know about other columns.

I do not know about MySQL so no comments on that.

The best way to learn HQL would be to try it out. Get hold of "Hibernate in Action" book, its a great help in learning NHibernate. Although it is for the java version but the API's are almost the same so you will not find any difficulty in using it.


Top
 Profile  
 
 Post subject: Re: HQL
PostPosted: Tue Feb 14, 2006 6:52 am 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
samujob wrote:
I think if you just plan to read the data you could write a class and map it to the subset of column you want to read (you have to include the PK ofcourse). This way NHibernate will only select the mapped columns when loading the object. However you will not be able to update/insert as NHibernate does not know about other columns.

I do not know about MySQL so no comments on that.

The best way to learn HQL would be to try it out. Get hold of "Hibernate in Action" book, its a great help in learning NHibernate. Although it is for the java version but the API's are almost the same so you will not find any difficulty in using it.


Samujob, but should I have to create one class for query? For example:

Code:
SELECT id, a FROM table


In this case, should I create a Class named A with the fields "id" and "a"?

I think there is another way...

Using HQL, it seems simple. But with ICriteria? Do you know?

Tks


Top
 Profile  
 
 Post subject: HQL
PostPosted: Tue Feb 14, 2006 7:37 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I do not think firing a HQL query like

SELECT mm.id, mm.a FROM class1 as mm will return you Objects of type class1. It will just return you an ArrayList of the values.


Top
 Profile  
 
 Post subject: Re: HQL
PostPosted: Tue Feb 14, 2006 8:07 am 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
samujob wrote:
I do not think firing a HQL query like

SELECT mm.id, mm.a FROM class1 as mm will return you Objects of type class1. It will just return you an ArrayList of the values.


Ok... this is the idea! Return just some fields (mm.id and mm.a, for example).

But do you know how do I return these fields using ICriteria?

Thanks


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