-->
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.  [ 4 posts ] 
Author Message
 Post subject: unexpected generated table structure(@JoinTable,@IndexColumn
PostPosted: Fri Mar 23, 2007 10:08 am 
Newbie

Joined: Tue Apr 25, 2006 9:35 am
Posts: 9
class SubMenu
{
@OneToMany(targetEntity=AbstractMenuItem.class,
cascade=CascadeType.MERGE,fetch=FetchType.EAGER)
@IndexColumn(name="position")
@JoinTable(name="relation_submenu_menuitem",
joinColumns={@JoinColumn(name="sub_menu_reference")},
inverseJoinColumns={@JoinColumn(name="menu_item_reference")})
public List<MenuItem> getMenuItems()
{
return menuItems;
}
...
}
My expected primary key of relation_submenu_menuitem is primary key{sub_menu_reference,menu_item_reference,position},but actual primary key is primary key{sub_menu_reference,position}.Only the combination of three columns can be primary key in my application.Can anyone help.

Thanks,
cheng


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 3:44 pm 
Newbie

Joined: Tue Apr 25, 2006 9:35 am
Posts: 9
i have a problem with @ManyToMany too.
class User
{
@ManyToMany(targetEntity=Card.class,fetch=FetchType.EAGER)
@JoinTable(name="relation_user_card",
joinColumns={@JoinColumn(name="user_reference")},
inverseJoinColumns={@JoinColumn(name="card_reference")})
public Set<Card> getCards()
{
return _cards;
}
...
}

class Card
{
@ManyToMany(targetEntity=User.class,fetch=FetchType.EAGER,mappedBy="cards")
public Set<User> getOwners()
{
return _owners;
}
...
}

when i invoke:
user.getCards().remove(card);
userDao.update(user);

relation_user_card relation table will not be updated to delete the relation between the user and that card(i checked generated sql,no sql for that).Only when i invoke user.getCards().clear(),then all relation for that user will be deleted from relation_user_card table.why does user not maintain the relation for the first situation?


any help,Thanks,
cheng


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 26, 2007 8:47 am 
Newbie

Joined: Tue Apr 25, 2006 9:35 am
Posts: 9
the second problem has been solved.
Any idea about the first problem.Thank you.

Thanks,
cheng


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 3:38 pm 
Newbie

Joined: Tue Apr 25, 2006 9:35 am
Posts: 9
does anyone encounter the first problem?I think it is a bug.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.