-->
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.  [ 3 posts ] 
Author Message
 Post subject: interfaces vs concrete classes in HQL
PostPosted: Sat Sep 25, 2004 12:39 pm 
Beginner
Beginner

Joined: Sun Aug 22, 2004 11:00 am
Posts: 21
Hibernate version:
2.1

is there some way to use inteface names in HQL instead of the concrete classes that are actually persisted?

i have a User interface and a UserImpl concrete class

i would like to be able to perform a 'find' such as the following:
Code:
User user=(User)session.find("from User as user where user.username=?", username, Hibernate.STRING);


Code:
<hibernate-mapping>

   <class name="friendnetwork.UserImpl" table="User">

      <id name="id">
         <generator class="foreign">
            <param name="property">blog</param>
         </generator>
      </id>

      <property name="username" unique="true"/>
      <property name="password"/>
      <property name="firstname"/>
      <property name="surname"/>
      <property name="email"/>
      <property name="created"/>
      <property name="modified"/>

      <one-to-one name="blog" class="friendnetwork.blog.BlogImpl" cascade="all"/>

   </class>
</hibernate-mapping>

_________________
Ive got a Tomcat that Struts then Springs then Hibernates


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 25, 2004 12:55 pm 
Beginner
Beginner

Joined: Sun Aug 22, 2004 11:00 am
Posts: 21
nevermind i figured it out.

one has to specify the fully qualified class name of the interface in the HQL. duh. such as:

Code:
User user = session.find("from friendnetwork.User as user where user.username=?", username, Hibernate.STRING);

_________________
Ive got a Tomcat that Struts then Springs then Hibernates


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 25, 2004 7:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is also the <import/> mapping element.


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