-->
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.  [ 4 posts ] 
Author Message
 Post subject: Database Views 2nd.
PostPosted: Thu Sep 11, 2003 3:58 am 
Newbie

Joined: Mon Sep 08, 2003 12:37 pm
Posts: 10
Hi!

Sorry for asking again, but nobody has answered.....

I have to select some data from a database view, which has no id column.
Is there any pattern it could be applied in this case. My mapping file contains:

<id type="java.lang.String">
<generator class="assigned"/>
</id>

I have a find class with a static method for the query:

public static List findxxx(Session session,String filterVal) throws SQLException, HibernateException
{
return session.find("from package.class where filterCol='"+filterVal+"'");
}

The query built contains reference to the id column, too, so the sql statement can not be executed( i don't want to use "select table.column...." returning Object[]).

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 7:15 pm 
Regular
Regular

Joined: Tue Sep 09, 2003 9:37 pm
Posts: 56
Location: Ogden, Utah, USA
Is that really ALL your mapping file has in it?

Does your view have nothing that makes a row unique? If it has some combination of fields they could be a composite-id.

Hope that helps. Your question is on the confusing side. :)

Jenica


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 9:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
If there is no PK, you should find a combination of columns which are unique, and map them as an "embedded" composite id.


P.S. The query you showed is probably incorrect. Property names should *always* be prefixed by an alias.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2003 2:50 am 
Newbie

Joined: Mon Sep 08, 2003 12:37 pm
Posts: 10
Thank you for your answers.

>>Is that really ALL your mapping file has in it?

No, the column mappings are there,too :).


>>If there is no PK, you should find a combination of columns which are unique, and map them as an "embedded" composite id.

I do not have desinger access to the view, so i cannot change it.

>> P.S. The query you showed is probably incorrect. Property names should *always* be prefixed by an alias.

Sorry it is my failure, I have an alias. The generated sql was absolute OK, the only problem was,that the id column was in the generated sql, too.

The documentation for "id" tag says:

"If the name attribute is missing, it is assumed that the class has no identifier property. "

That's why i thought, if one doesn't specify a name for the "id" tag, the generated sql will not contain the id column.
Do i understand it false?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.