If a have a entity like this(is just an example :D)

  | @Entity
  | @Name("person")
  | public class Person implements Serializable {
  |     private Long id;
  |     private String firstName;
  |     private String lastName;
  |     private int age;
  | 
  |     @Id
  |     @GeneratedValue
  |     public Long getId() {
  |         return id;
  |     }
  | 
  |     public void setId(Long id) {
  |         this.id = id;
  |     }
  | 
  |     @NotNull
  |     @Length(max=50)
  |     public String getFirstName() {
  |         return firstName;
  |     }
  | 
  |     public void setFirstName(String firstName) {
  |         this.firstName = firstName;
  |     }
  | 
  |     @NotNull
  |     @Length(max=50)
  |     public String getLastName() {
  |         return lastName;
  |     }
  | 
  |     public void setLastName(String lastName) {
  |         this.lastName = lastName;
  |     }
  | 
  |     @Min(0)
  |     public int getAge() {
  |         return age;
  |     }
  | 
  |     public void setAge(int age) {
  |         this.age = age;
  |     }    
  | }
  | 

And i would like to know how can i create a validation method telling seam to 
use the firstName and the lastName as a compound id for the entity without 
mapping that to the database?
I want to use the id property as the id for the mapping but the logic has to be 
in a method. If this logic is in a @PrePersist annotates method i can only 
compare the entity properties but not compare them with the persisted ones.

I would like to know how can i compare if there is an existent entity in the 
data source like the one i'm trying to persist. Maybe i have to override the 
equals method?
At witch layer do i have to do this validation rule? It would be ideal to have 
that logic in the domain model and not have it in some stateless or statefull 
bean.

Thanks in advance

Humber

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048860#4048860

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048860
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to