-->
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: Variable target column One-to-one mapping
PostPosted: Tue Sep 04, 2012 8:48 am 
Newbie

Joined: Tue Sep 04, 2012 8:37 am
Posts: 3
Is this possible to annotate a mapping where a relationship should be OR-ed between two (or more) possible target columns. My usecase:
Code:
@Table(name="cables")
class Cable {
    @Id
    private Long id;
    @Column(name="dstport_id")
    private Port dstPort;
    @Column(name="srcport_id")
    private Port srcPort;
}
@Table(name="ports")
class Port {
    @Id
    private Long id;
    private Cable cable; // Here's the mapping that should point to cables.dstport_id or cables.srcport_id whatever is present
}


So, in my case, a cable can be connected to 2 ports the same time (or just one, or none of them). This is a One-to-One mapping in my application. In SQL I'd select a cable corresponding this certain port like ' left join cables as c on c.srcport_id = id or c.dstport_id = id' or something like that. Is this possible to map the same way in Hibernate?


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.