Question

I have been fiddling with ormlite on android. It's early days and so far I really like what I have seen.

While reading the manual I noticed the ability to use javax.persistence annotation instead of the default. When trying to define a @ManyToOne relationship I cam a little unstuck. Normally I use a @JoinColumn(name="xxx") to defined the column name with a @ManyToOne, ie. not the @Column(name="xxx"). Am I right, or should I be looking at this a different way.

I had a quick look and thought a few small additions to com.j256.ormlite.misc.JavaxPersistence.java would resolve this issue. Basically the duplicating the code to handle the @Column to instead handle the @JoinColumn (maybe without the "length").

This also left me wondering is there were any issues with using both the standard ormlite annotations as well as the javax.persistence ones. Questions like:

  • do the standard annotations take precedence?, and
  • can the processing of javax.persistence annotations be disabled?
Was it helpful?

Solution

Unfortunately @user928550, the javax.persistence annotations are not completely supported by ORMLite. The limited support for them is defined in the manual:

http://ormlite.com/docs/jpa

I'd be happy to improve the support for them if you want to make suggestions about how to proceed. Please use the ORMLite developers mailing list to suggest your additions:

http://groups.google.com/group/ormlite-dev

In answer to you specific questions, existence of the @DatabaseField annotation will override any javax.persistence annotation processing and you cannot disable the processing of javax.persistence (unless you specify a @DatabaseField).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top