| Multitenancy and @EmbeddedId [message #965727] |
Wed, 31 October 2012 09:11  |
Ambroży Kleks Messages: 2 Registered: October 2012 |
Junior Member |
|
|
Hi,
Have simple entity with embeded ID:
@Entity
@Table(name = "customer", catalog = "db", schema = "")
@Multitenant(MultitenantType.SINGLE_TABLE)
@TenantDiscriminatorColumn(name = "tenant_id", contextProperty = "tenant.id", primaryKey = true)
@EmbeddedId
protected CustomerPK customerPK;
...
During start of application got errors:
Internal Exception: Exception [EclipseLink-7163] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class entity.Customer] has both an @EmbdeddedId (on attribute [customerPK]) and an @Id (on attribute []. Both ID types cannot be specified on the same entity.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1541)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1532)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:108)
The problem is, I have no @ID in my entity, so why eclipselink complains about that?
|
|
|
| Re: Multitenancy and @EmbeddedId [message #973636 is a reply to message #965727] |
Tue, 06 November 2012 08:51   |
James Sutherland Messages: 1834 Registered: July 2009 |
Senior Member |
|
|
My guess is it is related to your setting "primaryKey = true" in the @TenantDiscriminatorColumn. Try removing that.
It could be an issue with this flag and an @EmbeddedId, you could also try using an @IdClass instead.
If you can include your whole class, it would be easier to understand.
James : Wiki : Book : Blog
|
|
|
|
| Re: Multitenancy and @EmbeddedId [message #982950 is a reply to message #974673] |
Tue, 13 November 2012 10:04   |
James Sutherland Messages: 1834 Registered: July 2009 |
Senior Member |
|
|
Please log a bug for the issue with the EmeddedId, I think this could be an issue in multitenancy.
Can you remove your EmbeddedId, and remove using the TENANT_ID as part of your primary key? You could use a generated id instead.
Note, that you can put an @Column annotation on the Embeddedable that defines the EmbeddedId.
James : Wiki : Book : Blog
|
|
|
|
Powered by
FUDForum. Page generated in 0.06684 seconds