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.  [ 6 posts ] 
Author Message
 Post subject: Have I to use mapping everytime?
PostPosted: Thu Aug 30, 2007 10:29 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 1:25 pm
Posts: 26
Location: Recife, PE, Brazil
In my application I have a database view. (sql server express)

This requisite is not necessarily a business object. I wouldn't like to create a object just to agree NHibernate architecture.

there are few other cases that I will have that behavior.

I've tried this..


Quote:

NHibernate.IQuery query = NHibernateSessionModule.Session.CreateQuery("select * from TagsView");
IList data = query.List();



but I get this error...


{"in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [select * from TagsView]"}



The question are:

- returning collections using queries without object mapping
- returning a simple data like the amount of records in the dataabse

How would I solve this problem?[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 7:48 am 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html#d0e8963.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 12:15 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 1:25 pm
Posts: 26
Location: Recife, PE, Brazil
that didn't work.

I just get an error saying sth like "No Type specified"

What have I to do (configuration?) in order to work without mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 12:19 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Did you try using the alias-to-bean result transformer? (see 13.1.5)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 5:14 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 1:43 pm
Posts: 22
oalexandrino wrote:
that didn't work.

I just get an error saying sth like "No Type specified"

What have I to do (configuration?) in order to work without mapping?

You can use AliasToEntityMapResultTransformer to return data as dictionary.

If you just want to use your objects without mapping, you can do something like this:

For example, in HQL you can say something like this:
Code:
select new MyMappedClass(x.id, x.name) From blabla as x

Obviously, this needs mapping for MyMappedClass. But, you can also use this:
Code:
select new System.Collections.DictionaryEntry(x.id, x.name) From blabla as x

So, if you want this:
Code:
select new MyNamespace.MyNOTMappedClass(x.id, x.name) From blabla as x

you have to add an <import> somewhere in mapping file:
Code:
<import class='MyNamespace.MyNOTMappedClass, MyAssembly'>
.
NOTE <import> should be placed before <class>
Also, you could try using NHibernate.Cfg.Mappings.AddImport

HTH, Tom


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 12, 2007 12:50 pm 
Beginner
Beginner

Joined: Wed Aug 29, 2007 1:25 pm
Posts: 26
Location: Recife, PE, Brazil
I got what you said!

But I'd like to see a real example.

Would you mind sending me a link that contains an example, please?

anyway I'll look for it on the internet.

thanks!


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