-->
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: SQL View with Annotations
PostPosted: Tue Oct 07, 2008 4:21 pm 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
Hey guys,

I am trying to use annotations with a sql View.

There is no unique keys in Views, so I am trying to build a composite @Id.
The problem is that the two columns that I want to annotate are both @ManyToOne.

Is there a way to do this? I'm finding it hard to find any information on this in the forums or documentation.

Code:
@SuppressWarnings("serial")
@Entity
@Table(name = "vPhysicianPanelPayment", schema = "dbo")
@IdClass(value = PhysicianPanelPaymentCompositePk.class)
public class PhysicianPanelPayment extends DomainObject {

    @Id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PanelMembershipUID", nullable = false)
    private PanelMembership panelMembership;

    @Id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PhysicianUID", nullable = false)
    private Physician physician;

...
...
}

@Embeddable
class PhysicianPanelPaymentCompositePk implements Serializable {
    private PanelMembership panelMembership;
    private Physician physician;

    public PanelMembership getPanelMembership() {
        return panelMembership;
    }

    public Physician getPhysician() {
        return physician;
    }

    public void setPanelMembership(PanelMembership panelMembership) {
        this.panelMembership = panelMembership;
    }

    public void setPhysician(Physician physician) {
        this.physician = physician;
    }
}



Thanks so much.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 9:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

your usecase is possible. If you have a look at the tests within the annotation distribution you will see that there is a class StoreCustomer and StoreCustomerPK with match your use case.

Do you have a concrete problem?

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2008 9:25 am 
Beginner
Beginner

Joined: Tue Aug 12, 2008 9:06 am
Posts: 22
Location: Fort Washington, PA
Sorry, I ended up just changing my view to give me a unique column to map to.

Thanks for the response.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.