-->
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.  [ 2 posts ] 
Author Message
 Post subject: One-To-One Prevent Join
PostPosted: Fri Dec 01, 2017 2:22 pm 
Newbie

Joined: Fri Dec 01, 2017 2:12 pm
Posts: 1
I have a scenario were I need to query a table that has a One-To-One as part of the ID. I want to speed up the query by not performing the join that automatically occurs. In the past I've had to take the columns that map to the One-To-One and create readonly properties and query off them. Is there a better way to prevent this join?

Examples

[code]
class A {
@Id
@OneToOne
@JoinColumns({
@JoinColumn(name = "prefix", referencedColumnName = "prefix"),
@JoinColumn(name = "number", referencedColumnName = "number")
})
private B b;

@Column(name = "prefix", nullable = false, length = 3, insertable = false, updatable = false)
private String prefix;

@Column(name = "number", nullable = false, length = 10, insertable = false, updatable = false)
private String number;
}
[/code]


Top
 Profile  
 
 Post subject: Re: One-To-One Prevent Join
PostPosted: Fri Dec 01, 2017 2:50 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Just set LAZY on the @OneToOne association:

Code:
@OneToOne(detch = FetchType.LAZY)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.