openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc LaPierre" <mlapie...@rim.com>
Subject @ManyToMany mapping with extra data
Date Thu, 14 Feb 2008 20:05:37 GMT
Hi all,

I'm trying to do a ManyToMany mapping with additional data in the link
table. Here's a sample: 

@Entity
public class Foo
{
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int fooId;
}

@Entity
public class Bar
{
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int barId;
}

@Entity
public class FooBar
{
	//the primary key is fooId + barId in the database

	@ManyToOne
	@JoinColumn(name="fooId")
	private Foo foo;
	
	@ManyToOne
	@JoinColumn(name="barId")
	private Bar bar;

	private int thisIsFooBared;
}


I've tried several variations of this including adding @Id, but no luck.
I get the following exception: 


---------------------------------------------

org.apache.openjpa.persistence.PersistenceException: Attempt to update
the sequence table "OPENJPA_SEQUENCE_TABLE" failed.  The sequence table
is typically created when you run the mappingtool's refresh action on
any datastore identity class. If you have not run the mappingtool but
want to create the sequence table, run:
java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.
java:3849)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:97
)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:75
)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSe
q.java:346)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.ja
va:247)
	at
org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java
:60)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStore
Manager.java:549)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(Delegati
ngStoreManager.java:134)
	at
org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerIm
pl.java:501)
	at
org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.jav
a:2770)
	at
org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
	at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.
java:940)
	at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1884)
	at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1844)
	at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:17
62)
	at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime
.java:81)
	at
org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1292)
	at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:
861)
	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImp
l.java:408)
	... 23 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Invalid
object name 'OPENJPA_SEQUENCE_TABLE'. {prepstmnt 21539046 SELECT
SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? [params=(int)
0]} [code=208, state=S0002]
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConne
ctionDecorator.java:192)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$800(Loggin
gConnectionDecorator.java:57)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection
$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:8
44)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(Del
egatingPreparedStatement.java:262)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(Del
egatingPreparedStatement.java:252)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.getSequence(TableJDBCSeq.jav
a:442)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.setSequence(TableJDBCSeq.jav
a:483)
	at
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSe
q.java:343)
	... 38 more

---------------------------------------------

This table should not be using a sequence or any other kind of generated
ID -- only the 2 foreign keys should act as the identity.

Any thoughts?

Thanks,

Marc

---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged
material (including material protected by the solicitor-client or other applicable privileges),
or constitute non-public information. Any use of this information by anyone other than the
intended recipient is prohibited. If you have received this transmission in error, please
immediately reply to the sender and delete this information from your system. Use, dissemination,
distribution, or reproduction of this transmission by unintended recipients is not authorized
and may be unlawful.

Mime
View raw message