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

Unsupported type #10

Open
asinghal opened this issue Nov 4, 2011 · 8 comments
Open

Unsupported type #10

asinghal opened this issue Nov 4, 2011 · 8 comments

Comments

@asinghal
Copy link

asinghal commented Nov 4, 2011

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)

@mandubian
Copy link
Owner

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.

@asinghal
Copy link
Author

asinghal commented Nov 4, 2011

;-)

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.

@mandubian
Copy link
Owner

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

@asinghal
Copy link
Author

asinghal commented Nov 4, 2011

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

@mandubian
Copy link
Owner

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.

@asinghal
Copy link
Author

asinghal commented Nov 4, 2011

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

@mandubian
Copy link
Owner

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!

@asinghal
Copy link
Author

asinghal commented Nov 4, 2011

no problem! scala is cool indeed :-)

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

2 participants