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: SQL queries with properties mapped to several columns
PostPosted: Fri Nov 23, 2007 3:05 pm 
Newbie

Joined: Sun Jan 15, 2006 11:51 am
Posts: 8
Hibernate version: 1.20

Suppose I have a class with 3 properties A, B, C. I want to select all properties except one (C for example). If I do:


Code:
IList myClasses = session.CreateSQLQuery(@"select A as {c.A}, B as {c.B} from MyClass c"
    .AddEntity("c", typeof(MyClass))
    .List();


I've got IndexOutOfRangeException (C not specified). If I do:

Code:
IList myClasses = session.CreateSQLQuery(@"select A as {c.A}, B as {c.B}, null as {c.C}"
    .AddEntity("c", typeof(MyClass))
    .List();


I've got QueryException: SQL queries only support properties mapped to a single column - property [C] is mapped to 3 columns. Because unfortunately the C property is mapped to 3 columns (what a surprise!).

How can I skip the selecting of such properties and why must I supply names for all that properties if I need to select only some of them?

Thanks.


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.