openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vlad Tatavu <>
Subject RE: MappingTool does not create "not null" column for @ManyToOne(optional=false)
Date Fri, 12 Jan 2007 21:26:51 GMT
I don't have the OpenJPA code, so I cannot look at it.

You are right, OpenJPA will enforce the constraint in Java, but I expect 
the MappingTool to apply the NOT NULL to the database for the attribute 
that is annotated with @ManyToOne - not to the "remote" attribute.

public class TestAssociation {
        public int id;
        TestEntity assoced;
The MappingTool executes the following commands for this class:
CREATE TABLE TestAssociation (id INTEGER NOT NULL, assoced_id INTEGER, 
TestEntity (id)

I expect the TestAssociation.assoced_id to be NOT NULL, not is NOT NULL already because it is primary key.


"Patrick Linskey" <> 
12/01/2007 04:00 PM
Please respond to


RE: MappingTool does not create "not null" column for 

See if optional is false,
then OpenJPA (not the database) will throw an exception if a null is
specified. This is not propagated to foreign key constraints; those
should be configured via the @ForeignKey annotation, by setting the
updateAction appropriately.


Patrick Linskey
BEA Systems, Inc. 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Vlad Tatavu [] 
> Sent: Friday, January 12, 2007 12:44 PM
> To:
> Subject: MappingTool does not create "not null" column for 
> @ManyToOne(optional=false)
> If I use @ManyToOne(optional=false) to annotate an attribute, the 
> MappingTool does not create a NOT NULL column in the 
> corresponding table. 
> Bug?
> Vlad

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message