openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "klaasjan elzinga" <klaasjanelzi...@gmail.com>
Subject DDL for foreign key constraints.
Date Thu, 06 Sep 2007 20:40:13 GMT
Hi there,

I am trying to get openjpa to generate foreign key constraints. I have
to following annotations:

... on the parent:

    @OneToMany(targetEntity=Message.class, cascade=CascadeType.ALL,
mappedBy="mailingList")
    private List<Message> messages = new ArrayList<Message>();


... on the child

    @ManyToOne(targetEntity=MailingList.class, optional=false)
    @JoinColumn(referencedColumnName="id", table="mailinglist")
    private MailingList mailingList;

But openjpa w/ mysql does not generate a foreign key constraint:
mysql> show create table message;
| message | CREATE TABLE `message` (
  `id` bigint(20) NOT NULL,
  `state` smallint(6) default NULL,
  `version` int(11) default NULL,
  `mailingList_id` bigint(20) default NULL,
  PRIMARY KEY  (`id`),
  KEY `I_MESSAGE_MAILINGLIST` (`mailingList_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

Am I missing something? (besides the constraint ;)

Regards,

KlaasJan

Mime
View raw message