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;








1















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.










share|improve this question


























  • 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

















1















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.










share|improve this question


























  • 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













1












1








1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












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
);



);














draft saved

draft discarded
















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.




















draft saved

draft discarded















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현