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: @Where clause with @MappedSuperclass?
PostPosted: Sun Oct 26, 2008 10:24 pm 
Newbie

Joined: Fri Jun 18, 2004 11:29 am
Posts: 3
Hello,

Please see the mapping below.

Is there any way to move the @OneToMany mapping into the @MappedSuperclass? I can't see how, because the @Where clause requires a constant value. I would like to do something like :
@Where(clause="entityClass=" + this.class.simpleName)

Thanks for any suggestions!

Hibernate version:
3.2.6.ga

Mapping documents:
Code:
@Entity
public class EntityLog implements Serializable {
   @Id Integer id;
   Integer entityId;
   String entityClass;
}

@Entity
public class MyEntity extends BaseEntity implements Serializable {
   @Id Integer id;
   // Uni-directional OneToMany
   @OneToMany
   @JoinColumn(name="entityId")
   @Where(clause="entityClass='MyEntity'")
   private List<EntityLog> logEntries = new ArrayList<EntityLog>(0);
}

@MappedSuperclass
public class BaseEntity {
}


Name and version of the database you are using:
Oracle 10G

The generated SQL (not really, but this is easier to read :-)
Code:
select * from MyEntity e, EntityLog log
where log.entityId = e.entity.id
and log.entityClass = 'MyEntity'


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.