Giter Club home page Giter Club logo

datanucleus-scala's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

datanucleus-scala's Issues

Problem with Option and column names

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.-

Update pom.xml so that it works with Eclipse m2e

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

Option[Date] do not work as expected on JDOQL

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.-

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.