datanucleus / datanucleus-scala Goto Github PK
View Code? Open in Web Editor NEWDataNucleus support for Scala language features
DataNucleus support for Scala language features
Hi,
I don't know if this is the place for this. I apologize if it is not, but it is the best one I could find.
I was able to figure how to use datanucleus-scala for using scala Option in persistent fields, but it only works when the name of the field and the name of the database row are the same. For instance:
@persistent
@column(name = "pais_telcode", jdbcType = "VARCHAR")
var phoneCode: Option[String] = None
Does not work as pais_telcode is ignored. It works if I do:
@persistent
var pais_telcode: Option[String] = None
Because the field name now is the same as the row in database. Maybe I am doing something wrong?
Best,
Kurt.-
Currently if you have this project open in Eclipse it gives 4 errors, things like
ScalaOptionHandler cannot be resolved to a type
The method newContainer(AbstractMemberMetaData, Object...) of type OptionHandler must override or implement a supertype method
Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.2.1
Need it fixing to build cleanly, by someone who understands Scala and m2e
Hi again,
I think that I've found a bug in Datancleus 5.0.6 when used with Scala:
Let's say that we have a persistent class with a column like this:
@Column(name = "con_start")
var start: Option[Date] = None
While persistence works well with Options, I've found problems when doing JDOQL queries:
"SELECT FROM classname WHERE start.getYear == 2017"
trhows a:
Dispatching request: javax.jdo.JDOException: Cannot invoke method "YEAR" on expression "org.datanucleus.store.rdbms.sql.expression.SingleCollectionExpression@2318285f"
at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:681)
at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:449)
at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:276)
Then I though that start is treated as a collection and tried something like:
"SELECT FROM classname WHERE start.get(0).getYear == 2017"
But this throws:
Invocation of method "get" on "java.util.Date" is not supported org.datanucleus.exceptions.NucleusUserException: Invocation of method "get" on "java.util.Date" is not supported at
org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory.getMethod(SQLExpressionFactory.java:469) at
org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory.invokeMethod(SQLExpressionFactory.java:300) at
org.datanucleus.store.rdbms.sql.expression.DelegatedExpression.invoke(DelegatedExpression.java:141) at
org.datanucleus.store.rdbms.query.QueryToSQLMapper.processInvokeExpression(QueryToSQLMapper.java:4018) at
org.datanucleus.store.rdbms.query.QueryToSQLMapper.processInvokeExpression(QueryToSQLMapper.java:3877)
And now it is correctly treated as a java.util.Date but I've not found any way to do a getYear or any other JDOQL accepted method on a Date. Also tried to do a get as if start was an Optional, but the result is the same.
Maybe I am missing something, but it seems to me that this is not the expected behaviour so I let you know.
I just did a workaround and just avoid persistent Option[Date] fields if I want to use them on JDOQL, and then I have a non persistent lazy val on Scala that returns the Option. It works but its a bit awkward
Regards,
Kurt.-
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.