ClassCastException when storing UUIDS as VARCHAR in postgres

633 views
Skip to first unread message

lemona...@gmail.com

unread,
Mar 9, 2017, 5:28:36 AM3/9/17
to Ebean ORM
I'm upgrading from Play 2.4.8 to 2.5.12 and upgrading the sbt-play-ebean plugin from 2.0.0 to 3.0.0 (ebean 6.18.1). Primary keys are stored as UUID in my java models, and VARCHAR in postgres.
Anytime I try to find or save an object I get the following exception ClassCastException:

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.UUID
        at com.avaje.ebeaninternal.server.type.ScalarTypeUUIDNative.read(ScalarTypeUUIDNative.java:42)
        at com.avaje.ebeaninternal.server.type.ScalarTypeUUIDNative.read(ScalarTypeUUIDNative.java:17)
        at com.avaje.ebeaninternal.server.deploy.BeanProperty.read(BeanProperty.java:581)
        at com.avaje.ebeaninternal.server.deploy.id.IdBinderSimple.readSet(IdBinderSimple.java:169)
        at com.avaje.ebeaninternal.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:237)
        at com.avaje.ebeaninternal.server.query.CQuery.readNextBean(CQuery.java:431)
        at com.avaje.ebeaninternal.server.query.CQuery.hasNext(CQuery.java:512)
        at com.avaje.ebeaninternal.server.query.CQuery.readCollection(CQuery.java:543)
        at com.avaje.ebeaninternal.server.query.CQueryEngine.findMany(CQueryEngine.java:302)
        at com.avaje.ebeaninternal.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:94)

I understand that since 6.10.1 ebean has supported native UUIDs in postgres as well as VARCHAR, but for some odd reason it's trying to use ScalarTypeUUIDNative instead of ScalarTypeUUIDVarchar.
I can't be the first to come across this but I can't find this addressed anywhere online.

Tim Dörnemann

unread,
Sep 13, 2018, 6:00:36 AM9/13/18
to Ebean ORM
It's been a long time since the issue was posted, but has anyone run into the same problem and found a solution?
I'm facing the same issue when trying to upgrade from play 2.4 to 2.6. I'm also using Postgres, UUID in the Java model and varchar in the DB schema.

Thanks, Tim

Rob Bygrave

unread,
Sep 13, 2018, 5:36:27 PM9/13/18
to ebean@googlegroups
> upgrade from play 2.4 to 2.6

The Play version is somewhat irrelevant. What is relevant is the version of Ebean you are upgrading to.  

For current Ebean refer to: 

ServerConfig.setDbUuid(...) is the configuration which sets the UUID mode to use.



Cheers, Rob.



--

---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Dörnemann

unread,
Sep 15, 2018, 2:03:47 PM9/15/18
to eb...@googlegroups.com
Great, thanks Rob -- problem solved.
Reply all
Reply to author
Forward
0 new messages