-->
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: Cannot Using More Than One Restriction in @WhereJoinTable
PostPosted: Tue Jun 01, 2010 4:42 am 
Newbie

Joined: Tue Jun 01, 2010 4:18 am
Posts: 11
Hi.. Im a new user on this forum. I have a little problem using hibernate and @WhereJoinTable if I try to add more than one restriction at the 'clause'.

Suppose I have a data model like this:

Code:
public class ForeignPerson implements Serializable {
  private Long id;
  private List<IdentityNumberHistory> identityHistories;
  private transient IdentityNumberHistory currentTemporalIdentity;
  private transient IdentityNumberHistory currentPermenentIdentity;
  // Other property, getter, setter.
 
  @OneToMany(fetch=FetchType.LAZY, mappedBy="foreigner",
                 cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
  public List<IdentityNumberHistory> getIdentityHistories() {
    return this.identityHistories;
  }

 
  @Transient
  @OneToOne(fetch=FetchType.LAZY, mappedBy="foreigner")
  @WhereJoinTable(clause="CurrentIdentityNumber=true and IdentityNumberType='TEMPORAL'")
  public IdentityNumberHistory getCurrentTemporalIdentity() {
    this. currentTemporalIdentity = this.identityHistories.size() != 0 ?
    this.identityHistories.get(0) : new IdentityNumberCreationHistory();
   
    return this. currentTemporalIdentity;
  }

 
  @Transient
  @OneToOne(fetch=FetchType.LAZY, mappedBy="foreigner")
  @WhereJoinTable(clause="CurrentIdentityNumber=true and IdentityNumberType='PERMANENT'")
  public IdentityNumberHistory getCurrentPemanentIdentity() {
    this.currentPermenentIdentity = this.identityHistories.size() != 0 ?
    this.identityHistories.get(0) : new IdentityNumberCreationHistory();
   
    return this. currentPermenentIdentity;
  }
}


public class IdentityNumberHistory implements Serializable {
  private Long id;
  private ForeignPerson foreigner;
  // Other property, getter, setter.
}


When I try the code, the generated SQL is look like this:
Code:
select <blablabla> from identity_number_creation_history identitynu0_ where identitynu0_.IdentityNumberType=? and identitynu0_.ForeignPersonID=?

Where <blablabla> is selected fields in the query. As you may see, the where clause only ask for IdentityNumberType and ForeignPersonId, no criteria/where clause for CurrentIdentityNumber. When I remove one of criteria in @WhereJoinTable, it is works.

So, I suspect that the 'clause' in the @WhereJoinTable is in problem. Or, of course may be this is my fool and I hope one of you can help me out of this problem. Any suggestion will be so helpful.

The hibernate version is:
Specification-Title: Hibernate Core
Specification-Version: 3.3.1.GA
Specification-Vendor: Hibernate.org
Implementation-Title: Hibernate Core
Implementation-Version: 3.3.1.GA

Where it is a default hibernate version which bring by seam framework 2.2.0 GA.

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.