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

Cayenne 4.2.M1 testing #382

Closed
wants to merge 3 commits into from
Closed

Conversation

johnthuss
Copy link
Contributor

I'm trying out 4.2.M1 snapshot in order to provide testing feedback.

These changes aren't really meant to be applied directly, but to provide feedback into the issues I'm having.

  1. Joda time support is lacking in the class generation templates. I understand this is deprecated now, but since it hasn't been removed yet it should still work. Thinking ahead to the future there will need to a way for third parties to integrate Joda support into cayenne without having to create a hard fork. This doesn't appear to currently be possible - at least I don't know how to provide an additional Module to cgen via ant that could provide PropertyDescriptorCreator changes.

  2. I need to have a method like PropertyUtils.propertyTypeDefinition exposed so I can utilize it in my templates. The refactoring to move logic into PropertyUtils makes the templates clean and simple, but users need access to smaller pieces as well.

  3. Using "between" expressions on Joda time DateProperty instances fails. This is a bug that still needs to be fixed. I don't know where to start on this one.

  4. Ant's cgen task was completely broken. I doubt this is the correct fix, but it does get it running again.

@aarrsseni
Copy link
Contributor

Hi, John

  • Since 4.2 you can provide your own properties to cgen. This mechanic isn't described in docs.
  • Ant's cgen task is really broken. But the problem is not in adding cgenModule to Ant task.
    ServiceLoader doesn't work in Ant tasks. If you try to load services from code everything will be ok, but from task nothing will be found. Because of it autoloaded cgen module can't be added to Ant. Maybe you have some tips how to make CgenToolsModuleProvider visible to Ant task(is everything ok with ServiceLoader from Ant task?).
    If we fix loading cgen module to Ant you can create your own autoloaded module with custom properties and provide them to cgen. You can look to cgen module and PropertyDescriptorCreator to see how it works.
  • Another option is to create this properties in joda-module. According to this you can be able to add dependency of joda-module and this properties can be used.

@aarrsseni
Copy link
Contributor

There is fix for Ant cgen task 45877e8
Now you can provide custom properties.

  • First create your property
  • Create PropertyDescriptorCreator
  • Create autoloaded module with
    CgenModule.contributeUserProperties(binder) .insertBefore(CustomPropertyDescriptorCreator.class,NumericPropertyDescriptorCreator.class);
  • Then build jar and put it to libs folder
    This is short example of custom property https://github.com/aarrsseni/custom-property-example

@johnthuss
Copy link
Contributor Author

Thanks, except for the class loading issue I posted a pull request for, this works. The other issues that still need to be addressed are these, especially #3:

  1. I need to have a method like PropertyUtils.propertyTypeDefinition exposed so I can utilize it in my templates. The refactoring to move logic into PropertyUtils makes the templates clean and simple, but users need access to smaller pieces as well.

  2. Using "between" expressions on Joda time DateProperty instances fails. This is a bug that still needs to be fixed. I don't know where to start on this one. The stack trace is below, or can you run the failing test I pushed in the pull request:
    Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.joda.time.DateTime. Use setObject() with an explicit Types value to specify the type to use.
    at org.postgresql.jdbc.PgPreparedStatement.setObject(PgPreparedStatement.java:949)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setObject(HikariProxyPreparedStatement.java)
    at org.apache.cayenne.access.jdbc.SelectAction.bind(SelectAction.java:60)
    at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:93)
    at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:97)
    at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273)
    ... 46 more

@aarrsseni
Copy link
Contributor

Yes, there was a bug in between expression parsing.
Now it works.
6926928

@johnthuss johnthuss closed this May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants