It's probably just something I'm not seeing...

I have two entities in this relationship, Article and Account.  Accounts 
may have votes recorded for articles, and I track this by a many:many 
relationship between Articles and the Accounts that voted.  (One account 
may vote on many Articles, and Articles may have votes from many 
accounts.)

The symptom is that the Set annotated with @ManyToMany is always null and 
additions to the Set are not persisted.

I have a join table called article_votes which looks like this:

 article_object_id | integer | not null
 account_object_id | integer | not null

In Article.java, I've annotated articleVotes like this:

    @ManyToMany
    @JoinTable(name="article_votes", inverseJoinColumns = 
[EMAIL PROTECTED](name = "account_object_id", referencedColumnName = 
"object_id")})
    private Set<Account> articleVotes;

And in Account.java, I've annotated it like this:

    @ManyToMany
    @JoinTable(name = "article_votes", joinColumns = [EMAIL PROTECTED](name = 
"account_object_id")}, inverseJoinColumns = [EMAIL PROTECTED](name = 
"article_object_id")})
    private Set<Article> articleVotes;

The problem is that when I read an Article from the database, the 
articleVotes set is always null. If I create a HashSet and populated 
it and persist the change, OpenJPA performs no insert into the join table.

I can't imagine that Many:Many doesn't work, so it's probably some detail 
I'm overlooking.

Any thoughts or suggestions?

   Nick

-- 
"Courage isn't just a matter of not being frightened, you know. It's being
 afraid and doing what you have to do anyway."
   Doctor Who - Planet of the Daleks
This message has been brought to you by Nick Johnson 2.3b1 and the number 6.
http://healerNick.com/       http://morons.org/        http://spatula.net/

Reply via email to