Announcement Announcement Module
Collapse
No announcement yet.
Toplink ignores JPA annotations / porting Petclinic Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Costin Leau View Post
    You shouldn't couple the JPA annotations along with your classes.
    I am sorry, but I don't understand what do you mean by coupling annotations with classes.. My entity classes look like this:

    Code:
    package bt.entity;
    
    import javax.persistence.CascadeType;
    import javax.persistence.Column;
    import javax.persistence.DiscriminatorColumn;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Inheritance;
    import javax.persistence.InheritanceType;
    import javax.persistence.OneToOne;
    
    @Entity
    @Inheritance(strategy=InheritanceType.JOINED)
    // dla lepszej wydajności (vide: http://java.sys-con.com/read/286901.htm)
    @DiscriminatorColumn(name = "discriminator")
    public abstract class Person {
    	
    	@Id
    	@GeneratedValue(strategy = GenerationType.TABLE)
    	protected long id;
    	
    	@Column(length = 20, name="fName")
    	protected String firstName;
    	
    	@Column(length = 40, name="lName")
    	protected String lastName;
    	
    	@Column(length = 129) // wg. RFC 821
    	protected String email;
    
    	@Column(length = 20)
    	protected String tel;
    	
    	@OneToOne(cascade = CascadeType.ALL)
    	protected Address address;
    
    	public Address getAddress() {
    		return address;
    	}
    
    	public void setAddress(Address address) {
    		this.address = address;
    	}
    
    	public String getFirstName() {
    		return firstName;
    	}
    
    	public void setFirstName(String firstName) {
    		this.firstName = firstName;
    	}
    
    	/**
    	 * @return	imię <spacja> nazwisko
    	 */
    	public String getName() {
    		return this.firstName + " " + this.lastName;
    	}
    	
    	public long getId() {
    		return id;
    	}
    
    	public String getEmail() {
    		return email;
    	}
    
    	public void setEmail(String email) {
    		this.email = email;
    	}
    
    	public String getLastName() {
    		return lastName;
    	}
    
    	public void setLastName(String lastName) {
    		this.lastName = lastName;
    	}
    
    	public String getTel() {
    		return tel;
    	}
    
    	public void setTel(String tel) {
    		this.tel = tel;
    	}
    	
    	public Person(String firstName, String lastName, String email, String tel, Address address) {
    		this.firstName = firstName;
    		this.lastName = lastName;
    		this.email = email;
    		this.tel = tel;
    		this.address = address;
    	}
    
    	public Person() {
    	}
    	
    	@Override
    	public String toString() {
    		return getName() + ", " + getAddress().getTown();
    	}
    	
    	public String getNameAndEmailToFrom() {
    		return getName() + "<" + getEmail() + ">";
    	}
    }

    Comment


    • #17
      The problem are not your classes. What I suggest in order to get Toplink to work with annotations under Tomcat is to move the toplink essentials jar from your war under [TOMCAT]/shared/lib and [TOMCAT]/common/lib.

      Comment


      • #18
        Hey,

        I had an error identical to yours and after reading your post on Oracle's forum that said you had to move the toplink-essentials.jar to the shared folder in tomcat I am able to fix my problem. The solution for Tomcat 5.5.x includes moving both the toplink-essentials.jar and persistence.jar to the ${TOMCAT.HOME}/common/lib directory. Everything worked perfect after that.

        Comment

        Working...
        X