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 ?
|