Hibernate allows you to create types and override the fetching/saving metods of the types.
Create a type, e.g., InsertableOnly, which on the fetch sets throws away the database value.
Assuming your value is an Integer because you represent prices in cents to avoid rounding issues:
class InsertOnlyInteger extends org.hibernate.type.IntegerType {
public Object get(ResultSet rs, String name) throws SQLException {
return null;
}
}
Then make the Hibernate type of the attribute InsertOnlyInteger (with xml or annotation, as it suits you).
Eg to make a struct from a string >>> a = cast(packet, POINTER(A)).contents >>> a.x 258 >>> Or (this is identical to your method) >>> a = A() >>> a.x 0 >>> memmove(addressof(a), packet, sizeof(a)) 3083811008L >>> a.x 258 I think the second of those methods is promoted by the ctypes documentation. I'm not sure about the lifetimes of the .contents in the first method! And the reverse >>> string_at(addressof(a), sizeof(a)) '\x02\x01\x00\x00' >>>