-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any plans to support Hibernate 6? #21
Comments
Adapting to Hibernate 6 should not be too hard. For anyone looking to DYI, here's what public class BoxType implements UserType<Box> {
@Override
public int getSqlType() {
return java.sql.Types.OTHER;
}
@Override
public Class<Box> returnedClass() {
return Box.class;
}
@Override
public boolean equals(Box b1, Box b2) throws HibernateException {
if (b1 == null && b2 == null)
return true;
else if (b1 == null || b2 == null)
return false;
return b1.equals(b2);
}
@Override
public Box nullSafeGet(ResultSet resultSet, int position, SharedSessionContractImplementor sessionImplementor, Object owner)
throws HibernateException, SQLException {
PGbox value = (PGbox) resultSet.getObject(position);
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, Box box, int i, SharedSessionContractImplementor sessionImplementor) throws HibernateException, SQLException {
if (box == null) {
preparedStatement.setNull(i, java.sql.Types.OTHER);
} else {
preparedStatement.setObject(i, new PGbox(box.getP1().getX(), box.getP1().getY(),
box.getP2().getX(), box.getP2().getY()));
}
}
@Override
public Box deepCopy(Box b) throws HibernateException {
if (b == null)
return null;
try {
return (Box) b.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public boolean isMutable() {
return false;
}
@Override
public int hashCode(Box b) throws HibernateException {
return b.hashCode();
}
@Override
public Serializable disassemble(Box b) throws HibernateException {
return b;
}
@Override
public Box assemble(Serializable cached, Object owner) throws HibernateException {
return (Box) cached;
}
@Override
public Box replace(Box original, Box target, Object owner) throws HibernateException {
return original;
}
} |
Apologies for the delay, @pavilalopes .
|
We're not actually using this library for that kind of type, we're using it for the geometric types (point, etc). From what I can tell there is still no other library that covers these types. |
@pavilalopes : Totally makes sense. I would recommend you send a PR to |
No description provided.
The text was updated successfully, but these errors were encountered: