Hibernate Self Join Many to Many Mapping using self set of id'sHibernate recursive many-to-many association with the same entityHibernate many-to-many mapping and cascade=deleteCreate the perfect JPA entityHibernate: mapping many-to-one association to different parent table depending on type?Mapping a set in Hibernate with a composite primary keyOneToOne mapping on Non Primary-Key Join columnAssociation Hibernate mappingOne to Many and Many to One xml mapping in hibernate With Join tablesHibernate - One to Many Mapping of Set - AnnotationsHow to map many-to-many relation in Hibernate with a extra columns
Why do things cool down?
Is there any actual security benefit to restricting foreign IPs?
What is the word for a person who destroys monuments?
Can I separate garlic into cloves for storage?
Microservices and Stored Procedures
What are the end bytes of *.docx file format
What to do as a player when ranger animal companion dies
Is it safe to unplug a blinking USB drive after 'safely' ejecting it?
Removing rows containing NA in every column
Tips for remembering the order of parameters for ln?
Does battery condition have anything to do with macbook pro performance?
How does one calculate the distribution of the Matt Colville way of rolling stats?
Why do we need to use transistors when building an OR gate?
How do rulers get rich from war?
Is there a connection between IT and Ghostbusters?
What was the deeper meaning of Hermione wanting the cloak?
Inquiry answerer
All numbers in a 5x5 Minesweeper grid
How to count the number of function evaluations in NIntegrate
Can one guy with a duplicator initiate a nuclear apocalypse?
How was ownership of property managed during the Black Death, when so many original owners had died?
I reverse the source code, you negate the output!
Why is the stock market so unpredictable?
How is underwater propagation of sound possible?
Hibernate Self Join Many to Many Mapping using self set of id's
Hibernate recursive many-to-many association with the same entityHibernate many-to-many mapping and cascade=deleteCreate the perfect JPA entityHibernate: mapping many-to-one association to different parent table depending on type?Mapping a set in Hibernate with a composite primary keyOneToOne mapping on Non Primary-Key Join columnAssociation Hibernate mappingOne to Many and Many to One xml mapping in hibernate With Join tablesHibernate - One to Many Mapping of Set - AnnotationsHow to map many-to-many relation in Hibernate with a extra columns
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to create a new hibernate self many-to-many mapping using a set of Long Id's (self id's) what is the correct mapping for it?
I trying to create a mapping between Person and his friends(Persons off course)
I have a Person class map to a tbl_person table.
Person.java
public class Person
private Long personId;
private String name;
//much more properties in here make this object huge
private Set<Person> friends= new HashSet<Person>();
hibernate Person.hbm.xml mapping:
<set name="friends" table="friends" cascade="none" lazy="false">
<key column="friend_id"/>
<many-to-many column="person_id" class="com.kruders.model.bean.Person"/>
</set>
consider Person class extremely big.
Instead of doing:
Set<Person> friends
I want to use a set of Person Ids:
Set<Long> friendsIds
this way I won't be able to hold the entire Person object(again, very big) in memory.
hibernate xml mapping:
Expected results is a mapping table personId (foreign key to tbl_person) to friend (foreign key to tbl_person)
The id of that table is a composite of both columns.
tbl_friends
personId|friend
1 |2
1 |3
2 |1
Thank you.
java hibernate hibernate-mapping
add a comment
|
I'm trying to create a new hibernate self many-to-many mapping using a set of Long Id's (self id's) what is the correct mapping for it?
I trying to create a mapping between Person and his friends(Persons off course)
I have a Person class map to a tbl_person table.
Person.java
public class Person
private Long personId;
private String name;
//much more properties in here make this object huge
private Set<Person> friends= new HashSet<Person>();
hibernate Person.hbm.xml mapping:
<set name="friends" table="friends" cascade="none" lazy="false">
<key column="friend_id"/>
<many-to-many column="person_id" class="com.kruders.model.bean.Person"/>
</set>
consider Person class extremely big.
Instead of doing:
Set<Person> friends
I want to use a set of Person Ids:
Set<Long> friendsIds
this way I won't be able to hold the entire Person object(again, very big) in memory.
hibernate xml mapping:
Expected results is a mapping table personId (foreign key to tbl_person) to friend (foreign key to tbl_person)
The id of that table is a composite of both columns.
tbl_friends
personId|friend
1 |2
1 |3
2 |1
Thank you.
java hibernate hibernate-mapping
why don't you use lazy true?
– Syed Mehtab Hassan
Mar 28 at 16:51
Thank you for your answer. I will use lazy='true' but do you know how the correct mapping should be look like?
– Maor Shetrit
Mar 31 at 7:40
There is no way in my knowledge that keep only ids through mapping physically only id is stored but it referes to whole object
– Syed Mehtab Hassan
Mar 31 at 7:49
add a comment
|
I'm trying to create a new hibernate self many-to-many mapping using a set of Long Id's (self id's) what is the correct mapping for it?
I trying to create a mapping between Person and his friends(Persons off course)
I have a Person class map to a tbl_person table.
Person.java
public class Person
private Long personId;
private String name;
//much more properties in here make this object huge
private Set<Person> friends= new HashSet<Person>();
hibernate Person.hbm.xml mapping:
<set name="friends" table="friends" cascade="none" lazy="false">
<key column="friend_id"/>
<many-to-many column="person_id" class="com.kruders.model.bean.Person"/>
</set>
consider Person class extremely big.
Instead of doing:
Set<Person> friends
I want to use a set of Person Ids:
Set<Long> friendsIds
this way I won't be able to hold the entire Person object(again, very big) in memory.
hibernate xml mapping:
Expected results is a mapping table personId (foreign key to tbl_person) to friend (foreign key to tbl_person)
The id of that table is a composite of both columns.
tbl_friends
personId|friend
1 |2
1 |3
2 |1
Thank you.
java hibernate hibernate-mapping
I'm trying to create a new hibernate self many-to-many mapping using a set of Long Id's (self id's) what is the correct mapping for it?
I trying to create a mapping between Person and his friends(Persons off course)
I have a Person class map to a tbl_person table.
Person.java
public class Person
private Long personId;
private String name;
//much more properties in here make this object huge
private Set<Person> friends= new HashSet<Person>();
hibernate Person.hbm.xml mapping:
<set name="friends" table="friends" cascade="none" lazy="false">
<key column="friend_id"/>
<many-to-many column="person_id" class="com.kruders.model.bean.Person"/>
</set>
consider Person class extremely big.
Instead of doing:
Set<Person> friends
I want to use a set of Person Ids:
Set<Long> friendsIds
this way I won't be able to hold the entire Person object(again, very big) in memory.
hibernate xml mapping:
Expected results is a mapping table personId (foreign key to tbl_person) to friend (foreign key to tbl_person)
The id of that table is a composite of both columns.
tbl_friends
personId|friend
1 |2
1 |3
2 |1
Thank you.
java hibernate hibernate-mapping
java hibernate hibernate-mapping
edited Mar 28 at 14:35
roeygol
4,7985 gold badges31 silver badges62 bronze badges
4,7985 gold badges31 silver badges62 bronze badges
asked Mar 28 at 14:10
Maor ShetritMaor Shetrit
551 silver badge6 bronze badges
551 silver badge6 bronze badges
why don't you use lazy true?
– Syed Mehtab Hassan
Mar 28 at 16:51
Thank you for your answer. I will use lazy='true' but do you know how the correct mapping should be look like?
– Maor Shetrit
Mar 31 at 7:40
There is no way in my knowledge that keep only ids through mapping physically only id is stored but it referes to whole object
– Syed Mehtab Hassan
Mar 31 at 7:49
add a comment
|
why don't you use lazy true?
– Syed Mehtab Hassan
Mar 28 at 16:51
Thank you for your answer. I will use lazy='true' but do you know how the correct mapping should be look like?
– Maor Shetrit
Mar 31 at 7:40
There is no way in my knowledge that keep only ids through mapping physically only id is stored but it referes to whole object
– Syed Mehtab Hassan
Mar 31 at 7:49
why don't you use lazy true?
– Syed Mehtab Hassan
Mar 28 at 16:51
why don't you use lazy true?
– Syed Mehtab Hassan
Mar 28 at 16:51
Thank you for your answer. I will use lazy='true' but do you know how the correct mapping should be look like?
– Maor Shetrit
Mar 31 at 7:40
Thank you for your answer. I will use lazy='true' but do you know how the correct mapping should be look like?
– Maor Shetrit
Mar 31 at 7:40
There is no way in my knowledge that keep only ids through mapping physically only id is stored but it referes to whole object
– Syed Mehtab Hassan
Mar 31 at 7:49
There is no way in my knowledge that keep only ids through mapping physically only id is stored but it referes to whole object
– Syed Mehtab Hassan
Mar 31 at 7:49
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399672%2fhibernate-self-join-many-to-many-mapping-using-self-set-of-ids%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399672%2fhibernate-self-join-many-to-many-mapping-using-self-set-of-ids%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
why don't you use lazy true?
– Syed Mehtab Hassan
Mar 28 at 16:51
Thank you for your answer. I will use lazy='true' but do you know how the correct mapping should be look like?
– Maor Shetrit
Mar 31 at 7:40
There is no way in my knowledge that keep only ids through mapping physically only id is stored but it referes to whole object
– Syed Mehtab Hassan
Mar 31 at 7:49