I've searched a lot around internet and I didn't find any solution to my
problem. Any help will be so appreciated.
I'm using Servicemix 4.5.3 and I have all my dependencies installed (other
operations are running perfectly).I'm getting this exception with OpenJPA
application.persistence.entities.serviceregistry.Service.interfaces" defines
a target of "userId" for join column "userId", but that target does not
exist in table "Service"
I have the following entities.
@Entity
public class Service {
private ServicePK compositePrimaryKey;
private String wsdlFile;
private Collection<ServiceInterface> interfaces = new
HashSet<ServiceInterface>();
@EmbeddedId
public ServicePK getCompositePrimaryKey() {
return compositePrimaryKey;
...setters and getters
@ManyToMany
@JoinTable(name = "SERVICE_IMPLEMENTATION", joinColumns = {
@JoinColumn(name = "tenantId", referencedColumnName = "tenantId"),
@JoinColumn(name = "userId", referencedColumnName = "userId"),
@JoinColumn(name = "serviceName", referencedColumnName =
"serviceName") }, inverseJoinColumns = {
@JoinColumn(name = "interfaceName", referencedColumnName =
"interfaceName"),
@JoinColumn(name = "XMLNamespace", referencedColumnName =
"XMLNamespace") })
public Collection<ServiceInterface> getInterfaces() {
return interfaces;
ServicePK is another class to construct my composite primarykey is as
follow.
@Embeddable
public class ServicePK extends TenantUserOwnedEntityPK {
private String serviceName;
public ServicePK() {}
public ServicePK(String tenantId, String userId, String serviceName) {
super(tenantId, userId);
this.serviceName = serviceName;
public String getServiceName() {
return serviceName;
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
@Override
public boolean equals(Object obj) {
if (super.equals(obj) & obj instanceof ServicePK) {
ServicePK pk = (ServicePK) obj;
return this.serviceName.equals(pk.serviceName);
} else {
return false;
@Override
public int hashCode() {
return super.hashCode() + this.serviceName.hashCode();
Finally this PK has a super class to get another field for the composite
key.
@Embeddable
@MappedSuperclass
public class TenantUserOwnedEntityPK extends TenantOwnedEntityPK {
private String userId;
public TenantUserOwnedEntityPK() {}
public TenantUserOwnedEntityPK(String tenantId, String userId) {
super(tenantId);
this.userId = userId;
public String getUserId() {
return userId;
public void setUserId(String userId) {
this.userId = userId;
@Override
public boolean equals(Object obj) {
if (super.equals(obj) & obj instanceof TenantUserOwnedEntityPK) {
TenantUserOwnedEntityPK pk = (TenantUserOwnedEntityPK) obj;
return this.userId.equals(pk.userId);
} else {
return false;
@Override
public int hashCode() {
return super.hashCode() + this.userId.hashCode();
As you can see in this last class it's our field userId (The one that the
@ManyToMany relation complains about). When my DB is constructed from my
entities the Service table is as follow.
Table "public.service"
Column | Type | Modifiers
-------------+------------------------+-----------
tenantid | character varying(255) | not null
userid | character varying(255) | not null
servicename | character varying(255) | not null
wsdlfile | text |
Indexes:
"service_pkey" PRIMARY KEY, btree (tenantid, userid, servicename)
Referenced by:
TABLE "service_implementation" CONSTRAINT
"service_implementation_tenantid_fkey"
FOREIGN KEY (tenantid, userid, servicename)
REFERENCES service(tenantid, userid, servicename) DEFERRABLE
BTW I'm using Postgres 9.3.11 and openJPA 2.2.0.
How can I use that userId for a joincolumn in my relations? I have this kind
of mapping in other places and I'm getting the same error.
Thank you very much for everything.
problem. Any help will be so appreciated.
I'm using Servicemix 4.5.3 and I have all my dependencies installed (other
operations are running perfectly).I'm getting this exception with OpenJPA
application.persistence.entities.serviceregistry.Service.interfaces" defines
a target of "userId" for join column "userId", but that target does not
exist in table "Service"
I have the following entities.
@Entity
public class Service {
private ServicePK compositePrimaryKey;
private String wsdlFile;
private Collection<ServiceInterface> interfaces = new
HashSet<ServiceInterface>();
@EmbeddedId
public ServicePK getCompositePrimaryKey() {
return compositePrimaryKey;
...setters and getters
@ManyToMany
@JoinTable(name = "SERVICE_IMPLEMENTATION", joinColumns = {
@JoinColumn(name = "tenantId", referencedColumnName = "tenantId"),
@JoinColumn(name = "userId", referencedColumnName = "userId"),
@JoinColumn(name = "serviceName", referencedColumnName =
"serviceName") }, inverseJoinColumns = {
@JoinColumn(name = "interfaceName", referencedColumnName =
"interfaceName"),
@JoinColumn(name = "XMLNamespace", referencedColumnName =
"XMLNamespace") })
public Collection<ServiceInterface> getInterfaces() {
return interfaces;
ServicePK is another class to construct my composite primarykey is as
follow.
@Embeddable
public class ServicePK extends TenantUserOwnedEntityPK {
private String serviceName;
public ServicePK() {}
public ServicePK(String tenantId, String userId, String serviceName) {
super(tenantId, userId);
this.serviceName = serviceName;
public String getServiceName() {
return serviceName;
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
@Override
public boolean equals(Object obj) {
if (super.equals(obj) & obj instanceof ServicePK) {
ServicePK pk = (ServicePK) obj;
return this.serviceName.equals(pk.serviceName);
} else {
return false;
@Override
public int hashCode() {
return super.hashCode() + this.serviceName.hashCode();
Finally this PK has a super class to get another field for the composite
key.
@Embeddable
@MappedSuperclass
public class TenantUserOwnedEntityPK extends TenantOwnedEntityPK {
private String userId;
public TenantUserOwnedEntityPK() {}
public TenantUserOwnedEntityPK(String tenantId, String userId) {
super(tenantId);
this.userId = userId;
public String getUserId() {
return userId;
public void setUserId(String userId) {
this.userId = userId;
@Override
public boolean equals(Object obj) {
if (super.equals(obj) & obj instanceof TenantUserOwnedEntityPK) {
TenantUserOwnedEntityPK pk = (TenantUserOwnedEntityPK) obj;
return this.userId.equals(pk.userId);
} else {
return false;
@Override
public int hashCode() {
return super.hashCode() + this.userId.hashCode();
As you can see in this last class it's our field userId (The one that the
@ManyToMany relation complains about). When my DB is constructed from my
entities the Service table is as follow.
Table "public.service"
Column | Type | Modifiers
-------------+------------------------+-----------
tenantid | character varying(255) | not null
userid | character varying(255) | not null
servicename | character varying(255) | not null
wsdlfile | text |
Indexes:
"service_pkey" PRIMARY KEY, btree (tenantid, userid, servicename)
Referenced by:
TABLE "service_implementation" CONSTRAINT
"service_implementation_tenantid_fkey"
FOREIGN KEY (tenantid, userid, servicename)
REFERENCES service(tenantid, userid, servicename) DEFERRABLE
BTW I'm using Postgres 9.3.11 and openJPA 2.2.0.
How can I use that userId for a joincolumn in my relations? I have this kind
of mapping in other places and I'm getting the same error.
Thank you very much for everything.