Object Mapper - @Column, @Transient and getters

276 views
Skip to first unread message

Havhev Car My

unread,
Nov 15, 2016, 8:54:27 AM11/15/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi, while checking the solution for:

I'm migrating from driver 3.0.0 to 3.1.2,
While doing so iv'e realized the mapper started mapping getter methods as well as fields.

The thing that bugs me now is that a have some public "get*" or "is*" methods that calculate the result and do not return the value of some field (or a table column).
So now i have to go through all these methods and annotate them with @Transient. Problem is that it looks to me like a serious maintainability issue - each time i add to my class some method that starts with a "get" or "is" name, i have to remember to annotate it otherwise the mapper fails.

I think it would be nice to be able to tell the mapper to map only fields annotated with @Column.
Maybe as a property upon initialize or something.

Does it already exist and i missed that?
If not is it something that we can add?

Alexandre Dutra

unread,
Nov 15, 2016, 10:12:00 AM11/15/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi again,

Yes, since JAVA-636 has been released we have been receiving a few complaints similar to yours, which is why we logged JAVA-1310.

Basically your only solution right now is to annotate all undesired getters with @Transient.

In the future we might want to explore different strategies, such as:

- Make the annotation parsing logic configurable at mapper level (only fields, only getters, or both)
- Make the class hierarchy scan configurable at mapper level (scan the whole hierarchy, or just annotated classes)
- Make transient properties configurable at mapper level (should properties be transient by default or not)
- etc.

If you think you could benefit from such improvements, please vote for JAVA-1310 and, if possible, add a comment with your own ideas.

Thanks,

Alexandre

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.
--
Alexandre Dutra
Driver & Tools Engineer @ DataStax

Havhev Car My

unread,
Nov 15, 2016, 10:22:09 AM11/15/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Sounds great! Thanks!

Havhev Car My

unread,
Nov 16, 2016, 6:15:01 AM11/16/16
to DataStax Java Driver for Apache Cassandra User Mailing List
Hi Alexandre,

Is there any contribution guide in case i would like to implement and offer a pull request?
I saw the CLA so i guess i can contribute, so is there any additional technical guide..conventions, how to push, how to implement, etc?

Havhev Car My

unread,
Nov 16, 2016, 2:57:00 PM11/16/16
to DataStax Java Driver for Apache Cassandra User Mailing List
found it! (https://github.com/datastax/java-driver/blob/3.x/CONTRIBUTING.md)

Let me know if you have any comments or guides for this feature.

Kevin Gallardo

unread,
Nov 16, 2016, 4:08:23 PM11/16/16
to java-dri...@lists.datastax.com
Hi,

Thanks for offering to contribute!

I think we had discussed of the challenges of this feature on this PR: https://github.com/datastax/java-driver/pull/737, if that can give you a bit more context.

Concerning the code, we will comment on the PR directly if we have feedback to provide, but before starting to code I'd suggest proposing ideas on the JIRA ticket first and make sure the team and community have agreed on the points mentioned by Alexandre previously. i.e.: Shall we...
- Make the annotation parsing logic configurable at mapper level (only fields, only getters, or both)?
- Make the class hierarchy scan configurable at mapper level (scan the whole hierarchy, or just annotated classes)?
- Make transient properties configurable at mapper level (should properties be transient by default or not)?"

Cheers.

On Wed, Nov 16, 2016 at 8:56 PM, Havhev Car My <avivc...@gmail.com> wrote:
found it! (https://github.com/datastax/java-driver/blob/3.x/CONTRIBUTING.md)

Let me know if you have any comments or guides for this feature.

--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-user+unsubscribe@lists.datastax.com.



--
Kévin Gallardo.
Software Engineer in Drivers and Tools Team at DataStax.

Reply all
Reply to author
Forward
0 new messages