Skip to content
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

Upgrading to 4.5.0 causes class cast exception #72

Closed
davidbairdala opened this issue Aug 8, 2015 · 9 comments
Closed

Upgrading to 4.5.0 causes class cast exception #72

davidbairdala opened this issue Aug 8, 2015 · 9 comments

Comments

@davidbairdala
Copy link

I have a project that defines a domain object that has a Map property mapped to JsonMapType.

class MyDomainClass implements Serializable {

    Map customFields = [:]

    static mapping = {
        customFields type: JsonMapType
    }
}

Under version 4.4.0 the following works:

 def instance = MyDomainClass.get(params.id)

WIth version 4.5.0 the same code yields:

org.postgresql.util.PGobject cannot be cast to java.lang.String. Stacktrace follows:
Message: org.postgresql.util.PGobject cannot be cast to java.lang.String
    Line | Method
->>   49 | nullSafeGet in net.kaleidos.hibernate.usertype.JsonMapType

I am running against Postgres 9.3. Not sure if I'm doing something wrong, or if this is a bug introduced with 4.5.0.

Cheers, David.

@ilopmar
Copy link
Collaborator

ilopmar commented Aug 14, 2015

I'll try to reproduce it and create a test for it and fix it. I need to dig a little bit to see what change introduced in the last version broke that.

@ilopmar
Copy link
Collaborator

ilopmar commented Aug 15, 2015

I can't reproduce it from a test but I've been able to reproduce it from run-app.
The change was introduced in #65 to fix this issue #66.

I'm doing some test to fix this.

@eamon316
Copy link

Just came across this today. Looks as if the following will fix

String jsonString = ((PGobject)rs.getObject(names[0])).getValue();

as noted in [#66]

Is there a release planned to fix?

Thanks for all the effort +1 on the plugin

@ilopmar
Copy link
Collaborator

ilopmar commented Aug 26, 2015

I'll try to publish a new version during this week.

ilopmar added a commit that referenced this issue Sep 8, 2015
@ilopmar
Copy link
Collaborator

ilopmar commented Sep 8, 2015

I finally found the time to publish a new version. Fixed in 4.6.0 :-)

@ilopmar ilopmar closed this as completed Sep 8, 2015
@gregopet
Copy link
Contributor

I tried this and got exceptions when the field was null; currently using

        PGobject jsonObject = (PGobject)rs.getObject(names[0]);
        if (jsonObject != null) {
            return gson.fromJson(jsonObject.getValue(), userType);
        } else {
            return null;
        }

@ilopmar
Copy link
Collaborator

ilopmar commented Sep 24, 2015

That's was fixed in #77 and released in 4.6.1. Could you please try with that version?

@gregopet
Copy link
Contributor

I'm using the Grails 3 branch, I guess it wasn't ported to that branch yet?

@ilopmar
Copy link
Collaborator

ilopmar commented Sep 24, 2015

Yes, you're right. The last changes have not been applied to the 3.x branch. You need to wait until next week...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants