-->
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: How to add a single element in a table without loading it
PostPosted: Tue Apr 17, 2007 5:42 am 
Newbie

Joined: Thu Oct 06, 2005 5:36 am
Posts: 8
It's possible to add a single element into a table without loading the table and the related elements. It's a GUI use case where the users adds a new element 'PrepaymentModel' without loading the big underlying table.

Annotation :

@Entity
@Table(name = "CUSTOMER_BEHAVIOUR")
@AttributeOverride(name = "id", column = @Column(name = "CUSTOMER_BEHAVIOUR_ID", nullable = false))
@SequenceGenerator(name = "SEQ", sequenceName = "S_CUSTOMER_BEHAVIOUR")
public class CustomerBehaviourModel extends A
{
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "PREPAYMENT_MODEL_MAP", joinColumns = joinColumn(name = "CUSTOMER_BEHAVIOUR_ID"), inverseJoinColumns = @JoinColumn(name = "PREPAYMENT_MODEL_ID"))
@MapKeyManyToMany(joinColumns = @JoinColumn(name = "ACCOUNT_ID", nullable = false))
private Map<Account, PrepaymentModel> prepaymentModels = new HashMap();
...
}


A possible solution would be mapping the JoinTable with a new Annotated class (somehow we need to cheat on the Id...)


@Table(PREPAYMENT_MODEL_MAP)
class JoinTableClass
{
... these two are the key
@Column("CUSTOMER_BEHAVIOUR_ID")
long parentId;

@Column("ACCOUNT_ID")
long accountId;

@Column("PREPAYMENT_MODEL_ID")
PrepaymentModel prepModel;

}


Somebody has a more elegant solution
Thanks 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.