-->
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: Create an entity with a namedQuery and @Basic annotations
PostPosted: Wed Jun 17, 2009 5:51 pm 
Newbie

Joined: Wed Jun 17, 2009 5:27 pm
Posts: 9
I have an entity object that contains both persistent and transient data. The transient data from DetailTable and the persistent data comes from tableX. This entity is meant to be the detail entity in a master - detail relationship.

Code:
@NamedNativeQuery(
    name= "detail",
    query = "SELECT * FROM DetailTable"
    resultSetMapping ="detailMapping")

@SqlResultSetMapping(name="detailMapping",
    entities={@EntityResult(
        entityClass=VoucherItem.class,fields={@FieldResult(name="transientField",column="detailField")})})

@Entity
@Table(name = "tableX")
public class Detail implements Serializable() {
 
  @Basic
  private String persistentField

  @Transient
  private String transientField 
}



The master entity has a collection of the detail entity

Code:
@OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.ALL})
    @JoinColumn(name="detailID")
    private Collection<Detail> detail = new ArrayList<Detail>();
   
    public Collection<Detail> getDetail() {
        return detail;
    }

    public void setDetail(Collection<Detail> detail) {

    }


My question is how do I call the named query in the detail entity that loads the transient data?


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.