siena icon indicating copy to clipboard operation
siena copied to clipboard

Unsupported type

Open asinghal opened this issue 14 years ago • 8 comments

I am using Siena with Scala and it complains of java.util.Calendar and scala.BigDecimal as unsupported types.

play.exceptions.UnexpectedException: Unexpected Error at play.Play.start(Play.java:525) at play.Play.detectChanges(Play.java:610) at play.Invoker$Invocation.init(Invoker.java:186) at Invocation.HTTP Request(Play!) Caused by: siena.SienaRestrictedApiException: Siena[db=h2][api=createColumn] Restricted Usage - Message:Unsupported type for field models.Metric.vendorFunds at siena.jdbc.ddl.DdlGenerator.createColumn(DdlGenerator.java:257) at siena.jdbc.ddl.DdlGenerator.addTable(DdlGenerator.java:77) at play.modules.siena.SienaPlugin.onApplicationStart(SienaPlugin.java:148) at play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:425) at play.Play.start(Play.java:495)

asinghal avatar Nov 04 '11 06:11 asinghal

Yes

Calendar is not managed. Use classic Date instead. Calendar is a tool to manage time, not really a time container and also one the most catastrophic API in Java :D. I still wonder how we obtained this from a standardization process ;)

scala.BigDecimal is not managed as Siena is only Java for the time being (even if you can use it from Scala). But java.BigDecimal is managed and there is a doc in Siena github wiki about it. Moreover DDL (apache DDL) used by siena is a pure Java lib and no Scala there.

mandubian avatar Nov 04 '11 07:11 mandubian

;-)

anyways, is there a way i could still use these types in my scala code and specify another overriding (SQL/ Java ? ) data type (like a @Column annotation) ? If possible, I wouldn't want to use Java in my code just because of Siena.

asinghal avatar Nov 04 '11 08:11 asinghal

It's not trivial since this case hasn't been foreseen in Siena until now:) This is a case that should be imagined in the future to make Siena really compliant to Scala. Concerning the siena models, you must use java types because Siena doesn't know anything else, it's clear.

Then if you don't want to use any Java types in your Scala code, you should think of an implicit conversion. You write the corresponding class in pure Scala and write an implicit converter. It's only a workaround but I don't see any better way right now!

Pascal

mandubian avatar Nov 04 '11 08:11 mandubian

tried, it doesn't like implicit conversions either for some reason :-(

asinghal avatar Nov 04 '11 08:11 asinghal

Your implicit conversion must be completely external to the siena model. Siena can't analyze anything from Scala so if there are weird fields in the class, it will break for sure.

IMO, you must write a Java-style class for Siena and a mirrored pure-Scala class and a conversion from the Java-style class to the pure-Scala class.

mandubian avatar Nov 04 '11 08:11 mandubian

ah! hmm, sure i'll change my code to java data types for now, thanks for the tip!

asinghal avatar Nov 04 '11 08:11 asinghal

Sorry for that ;) Scala is gaining momentum, it's cool... I've been diving in it for a few month and I think it's a great evolution!

mandubian avatar Nov 04 '11 08:11 mandubian

no problem! scala is cool indeed :-)

asinghal avatar Nov 04 '11 09:11 asinghal