// Path: src/main/java/com/github/thealchemist/pg_hibernate/types/Box.java
// public class Box implements Serializable, Cloneable {
// 
// 	private final Point p1;
// 	private final Point p2;
// 
// 	public Box( Point p1, Point p2 ) {
// 		this.p1 = p1;
// 		this.p2 = p2;
// 	}
// 
// 	public Point getP1() {
// 		return p1;
// 	}
// 
// 	public Point getP2() {
// 		return p2;
// 	}
// 
// 	public int hashCode() {
// 		return p1.hashCode() + p2.hashCode();
// 	}
// 
// 	public boolean equals( Object obj ) {
// 		if (obj instanceof Box) {
// 			return (p1.equals(((Box) obj).p1) && p2.equals(((Box) obj).p2)) ||
// 					(p1.equals(((Box) obj).p2) && p2.equals(((Box) obj).p1));
// 		}
// 		return super.equals(obj);
// 	}
// 
// 	public Rectangle2D asRectangle2D() {
// 		return new Rectangle2D.Double(p1.getX(), p1.getY(), p2.getX() - p1.getX(), p2.getY() - p1.getY());
// 	}
// 
// 	public Object clone() throws CloneNotSupportedException {
// 		return super.clone();
// 	}
// }
// 
// Path: src/main/java/com/github/thealchemist/pg_hibernate/types/Point.java
// public class Point implements Serializable, Cloneable {
// 
// 	private final double x;
// 	private final double y;
// 
// 	public Point( double x, double y ) {
// 		this.x = x;
// 		this.y = y;
// 	}
// 
// 	public double getX() {
// 		return x;
// 	}
// 
// 	public double getY() {
// 		return y;
// 	}
// 
// 	public Point2D asPoint2D() {
// 		return new Point2D.Double(x, y);
// 	}
// 
// 	public boolean equals( Object obj ) {
// 		if (obj instanceof Point) {
// 			return x == ((Point) obj).x && y == ((Point) obj).y;
// 		}
// 		return super.equals(obj);
// 	}
// 
// 	public int hashCode() {
// 		return (int) x * 31 + (int) y;
// 	}
// 
// 	public Object clone() throws CloneNotSupportedException {
// 		return super.clone();
// 	}
// }


import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
import org.postgresql.geometric.PGbox;
import com.github.thealchemist.pg_hibernate.types.Box;
import com.github.thealchemist.pg_hibernate.types.Point;

        PGbox value = (PGbox) resultSet.getObject(names[0]);

        if (value == null) {
            return null;
        } else {
            Point p1 = new Point(value.point[0].x, value.point[0].y);
            Point p2 = new Point(value.point[1].x, value.point[1].y);
            return new Box(p1, p2);
        }
    }

    @Override
    public void nullSafeSet(PreparedStatement preparedStatement, Object value, int i, SharedSessionContractImplementor sessionImplementor) throws HibernateException, SQLException {
        Box rect = (Box) value;

        if (value == null) {
            preparedStatement.setNull(i, java.sql.Types.OTHER);
        } else {
            preparedStatement.setObject(i, new PGbox(rect.getP1().getX(), rect.getP1().getY(),
                    rect.getP2().getX(), rect.getP2().getY()));
        }
    }

    @Override
    public Object deepCopy(Object o) throws HibernateException {
        if (o == null)
            return null;
        
        try {
// Path: src/main/java/com/github/thealchemist/pg_hibernate/types/Box.java
// public class Box implements Serializable, Cloneable {
// 
// 	private final Point p1;
// 	private final Point p2;
// 
// 	public Box( Point p1, Point p2 ) {
// 		this.p1 = p1;
// 		this.p2 = p2;
// 	}
// 
// 	public Point getP1() {
// 		return p1;
// 	}
// 
// 	public Point getP2() {
// 		return p2;
// 	}
// 
// 	public int hashCode() {
// 		return p1.hashCode() + p2.hashCode();
// 	}
// 
// 	public boolean equals( Object obj ) {
// 		if (obj instanceof Box) {
// 			return (p1.equals(((Box) obj).p1) && p2.equals(((Box) obj).p2)) ||
// 					(p1.equals(((Box) obj).p2) && p2.equals(((Box) obj).p1));
// 		}
// 		return super.equals(obj);
// 	}
// 
// 	public Rectangle2D asRectangle2D() {
// 		return new Rectangle2D.Double(p1.getX(), p1.getY(), p2.getX() - p1.getX(), p2.getY() - p1.getY());
// 	}
// 
// 	public Object clone() throws CloneNotSupportedException {
// 		return super.clone();
// 	}
// }
// 
// Path: src/main/java/com/github/thealchemist/pg_hibernate/types/Point.java
// public class Point implements Serializable, Cloneable {
// 
// 	private final double x;
// 	private final double y;
// 
// 	public Point( double x, double y ) {
// 		this.x = x;
// 		this.y = y;
// 	}
// 
// 	public double getX() {
// 		return x;
// 	}
// 
// 	public double getY() {
// 		return y;
// 	}
// 
// 	public Point2D asPoint2D() {
// 		return new Point2D.Double(x, y);
// 	}
// 
// 	public boolean equals( Object obj ) {
// 		if (obj instanceof Point) {
// 			return x == ((Point) obj).x && y == ((Point) obj).y;
// 		}
// 		return super.equals(obj);
// 	}
// 
// 	public int hashCode() {
// 		return (int) x * 31 + (int) y;
// 	}
// 
// 	public Object clone() throws CloneNotSupportedException {
// 		return super.clone();
// 	}
// }


// Path: src/main/java/com/github/thealchemist/pg_hibernate/BoxType.java
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
import org.postgresql.geometric.PGbox;
import com.github.thealchemist.pg_hibernate.types.Box;
import com.github.thealchemist.pg_hibernate.types.Point;


        PGbox value = (PGbox) resultSet.getObject(names[0]);

        if (value == null) {
            return null;
        } else {
            Point p1 = new Point(value.point[0].x, value.point[0].y);
            Point p2 = new Point(value.point[1].x, value.point[1].y);
            return new Box(p1, p2);
        }
    }

    @Override
    public void nullSafeSet(PreparedStatement preparedStatement, Object value, int i, SharedSessionContractImplementor sessionImplementor) throws HibernateException, SQLException {
        Box rect = (Box) value;

        if (value == null) {
            preparedStatement.setNull(i, java.sql.Types.OTHER);
        } else {
            preparedStatement.setObject(i, new PGbox(rect.getP1().getX(), rect.getP1().getY(),
                    rect.getP2().getX(), rect.getP2().getY()));
        }
    }

    @Override
    public Object deepCopy(Object o) throws HibernateException {
        if (o == null)
            return null;
        
        try {
            return ((Box) o).clone();