Mon Apr 26, 2010 11:48 am
package com.codemiles.jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
@Entity
@Table(name="SHAPE")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Shape implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
protected int id;
protected int scale;
protected float rotate;
protected String colour;
protected String points;
protected int numOfPoints;
public Shape(){
id=(int)System.currentTimeMillis();
}
@Column(name="SHAPE_ID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="SCALE")
public int getScale() {
return scale;
}
public void setScale(int scale) {
this.scale = scale;
}
@Column(name="ROTATE")
public float getRotate() {
return rotate;
}
public void setRotate(float rotate) {
this.rotate = rotate;
}
@Column(name="POINTS")
public String getPoints() {
return points;
}
public void setPoints(String points) {
this.points = points;
}
public void setColour(String colour) {
this.colour = colour;
}
@Column(name="COLOUR")
public String getColour() {
return colour;
}
public void setNumOfPoints(int numOfPoints) {
this.numOfPoints = numOfPoints;
}
@Column(name="NUM_POINTS")
public int getNumOfPoints() {
return numOfPoints;
}
}
package com.codemiles.jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.AttributeOverride;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="CIRCLE")
@AttributeOverride(name="rotate", column=@Column(name="ROTATE_Circle"))
public class Circle extends Shape implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
protected float radius;
public Circle(){
super();
numOfPoints =1 ;
}
public void setRadius(float radius) {
this.radius = radius;
}
@Column(name="RADIUS")
public float getRadius() {
return radius;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.