Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
Created October 24, 2012 12:02
Show Gist options
  • Save nakamura-to/3945704 to your computer and use it in GitHub Desktop.
Save nakamura-to/3945704 to your computer and use it in GitHub Desktop.
An Embedded Value implementation in Doma
import org.seasar.doma.Entity;
import org.seasar.doma.Id;
@Entity
public class Dept {
@Id
private Integer id;
private String name;
private String city;
private int x;
private int y;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Location getLocation() {
return new Location(city, new Point(x, y));
}
public void setLocation(Location location) {
this.city = location.getCity();
this.x = location.getPoint().getX();
this.y = location.getPoint().getY();
}
}
public class Location {
private String city;
private Point point;
public Location(String city, Point point) {
this.city = city;
this.point = point;
}
public String getCity() {
return city;
}
public Point getPoint() {
return point;
}
}
public class Point {
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment