I'm implementing a small project and I'm wondering if ORMLite supports inverse mapping for @DatabaseMapping
s. What I am looking for is this similar to JPA's/Hibernates's inverse mapping. Following, hypothetical and rather silly example, a table BlogPost
:
@DatabaseTable public class BlogPost { @DatabaseField(foreign = true) private Author owner; }
and the according Author
class, not really that important:
@DatabaseTable public class Author { }
This results in the following SQL (just the relevant parts):
CREATE TABLE blogpost ( ... , owner_id INTEGER NOT NULL, ... )
CREATE TABLE author ( ... )
See how table blogpost now has a foreign key for author. However, I'd prefer it the other way around, i.e. author should have a blogpost_id foreign key. (I told you it was a silly example... ;).
With inverse mapping I could utilize cascades for deletes but I haven't found anything in the ORMlite docs about this. Is it not a feature or am I just missing something?