-->
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: FK to a view
PostPosted: Thu Jul 30, 2009 6:21 am 
Newbie

Joined: Mon Mar 10, 2008 8:55 am
Posts: 9
Hi,

I have a question concerning views:

Let's say I have mapped two classes A and B:

class A {
@Id
@Column(name="ID")
private Long id;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ID", insertable=false, updatable=false)
private B propertyB;
...
}

class B {
@Id
@Column(name="ID")
private Long id;

@OneToOne(fetch = FetchType.LAZY, mappedBy="propertyB")
private A propertyA;
...
}

I dropped B, and replaced it with a view. It works nicely, but every time I query form something on A, he does a select on B to see if it is null. Since the foreign key is actually the Id, there's no other way to check that.

It gives us a lot of overhead, so I tried to make a new foreign key. So instead of setting JoinColumn to 'ID', I set it to another column (f.e.'BID') and set a NotNull constraint so maybe hibernate could see whether it is null or not without querying for it.

That's not working though, cause he doesn't know what to enter as the value (offcourse) and he's trying to save B, which is not possible cause it's a view. Is there any other way to do this ?


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.