openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard Mak" <>
Subject RE: bidirectional one-to-many relationship with join-table
Date Tue, 08 Jun 2010 04:10:59 GMT
1.	Auto-create of tables is disabled.  I have <property
name="openjpa.jdbc.SynchronizeMappings" value="validate"/>

2.	Yes, there is an existing schema.  Following was manually
created on my SQLServer:

	CREATE TABLE person_addresses (
		person_ssn BIGINT references person,
		phone      VARCHAR(255) references address);

3.	The problem w/ suggested edit is that I cannot change the table
columns [to follow JPA conventions].  Instead, I need to make JPA fit
the existing schema. :(

4.	Is applying @SecondaryTable(name="person_addresses") on Address
entity a suitable workaround (... seems to avoid the exception I've been
getting)?  Any problems other than the performance hit [incurred by
extra join] when selecting Address?


5.	I've also noticed that on case sensitive SQLServer collations
(e.g., "Latin1_General_BIN"), I get the following exception on

		Exception in thread "main"
<openjpa-2.0.0-beta-r422266:903062M fatal user error>
org.apache.openjpa.persistence.ArgumentException: "model.Address.person"
declares column "ADDRESS_PHONE", but this column does not exist in table

	Does OpenJPA assume that DB collation is always case

Thanks for your help!

- Howard

-----Original Message-----
From: Pinaki Poddar [] 
Sent: Monday, June 07, 2010 11:28 PM
Subject: RE: bidirectional one-to-many relationship with join-table

  1. what is the settings for openjpa.jdbc.SynchronizeMappings property?
  2. is there an existing schema?
I ran your example as it is to define the schema on a MySQL databse.
It ended up with three columns on PERSON_ADDRESSES join table
   CREATE TABLE person_addresses (
      phone VARCHAR(255))

Quite possibly a bug.

Editing line 03 of your mapping spec 

01: @JoinTable(name="person_addresses",
02:      joinColumns = @JoinColumn(name="person_ssn",
03:       inverseJoinColumns = @JoinColumn(name="phone",

Edit line 03 to
   inverseJoinColumns = @JoinColumn(name="address_phone",

Got rid of the third column on the join table.
But obviously naming of join table's columns has a problem that requires
further investigation. 
But see if the suggested edit helps. 

View this message in context:
Sent from the OpenJPA Users mailing list archive at

This email and any files transmitted with it are confidential and intended solely for the
use of the individual or entity to whom they are addressed. Please note that any views or
opinions presented in this email are solely those of the author and do not necessarily represent
those of the company. Finally, the recipient should check this email and any attachments for
the presence of viruses. The company accepts no liability for any damage caused by any virus
transmitted by this email. If you have received this email in error please delete it and notify
the system administrator at

View raw message