I am trying to store jscience physics amounts in my grails project. I am using hibernate and defaults, but I would prefer something with general applicability. I am specifically concerned with Mass and if I could have my way I would just make a line in the domain object like so:
MyDomainClass {
Amount<Mass> weight
}
But that gives this error:
Caused by: org.hibernate.exception.DataException: could not insert: [project.MyDomainClass] at $Proxy10.saveOrUpdate(Unknown Source) ... 27 more Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'weight' at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3601) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2333) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2318) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ... 28 more
I can fix that error by changing it to
def weight
Is there anything wrong with that, or a better way? Is there any database solution with advantages for dealing with mixed units? Googling this is so frustrating because everything is about unit testing.