-->
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 do I do this???
PostPosted: Mon Jun 29, 2009 11:27 am 
Newbie

Joined: Tue May 19, 2009 7:51 am
Posts: 3
I am using hibernate and spring and I find the this question:

I have a class -> Batch

@Entity
@org.hibernate.annotations.Entity(mutable=false)
@Table(name="batch")
public class Batch {

private Long identifier;
private Person sellerParty;
...
@SequenceGenerator( // It only takes effect for
name="BatchIdGenerator", // databases providing identifier
sequenceName="BatchSeq") // generators.
@Id
@GeneratedValue(strategy=GenerationType.AUTO,
generator="BatchIdGenerator")
/**
* @return the identifier
*/
public Long getIdentifier() {
return identifier;
}

/**
* @param identifier the identifier to set
*/
public void setIdentifier(Long identifier) {
this.identifier = identifier;
}
...
/**
* @return the sellerParty
*/
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="seller_id")
public Person getSellerParty() {
return sellerParty;
}

/**
* @param sellerParty the sellerParty to set
*/
public void setSellerParty(Person sellerParty) {
this.sellerParty = sellerParty;
}
...
package es.corunet.facturgal.model.person;

and the class -> Person...

@Entity
@Table(name = "person")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Person {

private Long identifier;
private String personTypeCode;

...

@SequenceGenerator( // It only takes effect for
name="PersonIdGenerator", // databases providing identifier
sequenceName="PersonSeq") // generators.
@Id
@GeneratedValue(strategy=GenerationType.AUTO,
generator="PersonIdGenerator")
/**
* @return the identifier
*/
public Long getIdentifier() {
return identifier;
}

/**
* @param identifier the identifier to set
*/
public void setIdentifier(Long identifier) {
this.identifier = identifier;
}

...

/**
* @return the personTypeCode
*/
public String getPersonTypeCode() {
return personTypeCode;
}


/**
* @param personTypeCode the personTypeCode to set
*/
public void setPersonTypeCode(String personTypeCode) {
this.personTypeCode = personTypeCode;
}

I have BatchDaoHibernate y PersonDaoHibernate class that extend GenericDaoHibernate with the method

public void create(E entity) {
getSession().persist(entity);
}

Can I do that my aplication calls create if a person whith the same PersonTypeCode exists does not create a new person and use the old?

Thanks

Thanks


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.