kaleidos / grails-postgresql-extensions

Grails plugin to use postgresql native elements such as arrays, hstores,...
Apache License 2.0
78 stars 62 forks source link

Fixing enum array mapping issues #62

Closed mochalov closed 9 years ago

mochalov commented 9 years ago

Fixed exception:

Argument is not an array
java.lang.IllegalArgumentException: Argument is not an array
    at net.kaleidos.hibernate.usertype.ArrayType.nullSafeGet(ArrayType.java:109)
    at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:127)

Fixed enum to integer mapping issue: ArrayType.nullSafeGet expected getId() method on enum, but ArrayType.nullSafeSet used ordinal() result while saving

Caused by: java.lang.NoSuchMethodException: test.criteria.array.Like$Juice.getId()
    at java.lang.Class.getMethod(Class.java:1670)
    at net.kaleidos.hibernate.usertype.BidiEnumMap.<init>(BidiEnumMap.java:32)
    at net.kaleidos.hibernate.usertype.ArrayType.idToEnum(ArrayType.java:154)

Not plugin will try to use a result of getId() method as an identifier or will use ordinal() if such method is missing.

The main reason why fixed issues have not been reproduced when running integration tests is that domain saving and retrieving should be in different sessions. Only in that case Hibernate will invoke nullSafeGet on the corresponding user type and will not use current session's cache.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+5.55%) to 79.49% when pulling 22ab89b9ede35efa95fffce76cf62f8a372feea1 on mochalov:master into 1b90d71f9aa254679f6b3b87dfa5133d9004474d on kaleidos:master.

ilopmar commented 9 years ago

Thank you very much for the PR. We'll try to review it as soon as possible, merge it and generate a new version.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+5.55%) to 79.49% when pulling eadb95786b66e76852a5632cfcf5ddc789f4f041 on mochalov:master into 1b90d71f9aa254679f6b3b87dfa5133d9004474d on kaleidos:master.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+5.55%) to 79.49% when pulling eadb95786b66e76852a5632cfcf5ddc789f4f041 on mochalov:master into 1b90d71f9aa254679f6b3b87dfa5133d9004474d on kaleidos:master.

ilopmar commented 9 years ago

Merged!

Thank you very much :-)

ilopmar commented 9 years ago

Included in version 4.5.0