-->
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: OneToOne with no corresponding data on foreign table
PostPosted: Thu Jul 05, 2012 7:28 am 
Newbie

Joined: Thu Jul 05, 2012 7:11 am
Posts: 1
Hello

I want to avoid hibernate to do a select when there is no data on foreign table.
I explain :

I have 2 tables A and B with this kind of association
A(1...1) ----(0...1)B

If I load (with criteria) all datas on the table A, I have the correct behavior
Code:
Select * from A left outer join B on a.code=b.id

with a.code not primarykey of A table

But after I have some others selects:
Code:
Select * from B where id=?

Each time I have no B object according to the A object

In my actual case, I have 662 records, but only 4 records contain a mapping with B object ... So I have 658 selects to check if the B object exists in DB
It's inefficient ! But I don' know how fix it

this is my java code for the association :

Code:
@OneToOne( fetch = FetchType.EAGER, cascade = {
        CascadeType.ALL
    })
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "code", insertable = false, updatable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    public B getB() {
        return b;
    }


Note: I try with optional=true, but it's the same ...

Thanks in advance for your help


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.