-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Foreign key must have same number of columns as the referenc
PostPosted: Tue Nov 08, 2011 3:18 am 
Newbie

Joined: Tue Nov 08, 2011 3:13 am
Posts: 4
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
java.lang.ExceptionInInitializerError
Caused by: org.hibernate.MappingException: Foreign key (FK185958CF49BEAA68:PRODUCT [SERIALNUMBER])) must have same number of columns as the referenced primary key (PRODUCT [SERIALNUMBER,idx])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:112)
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:95)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1835)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1756)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at com.nd.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
Exception in thread "main"

I am trying to get a simple map to persist but without success any help is appreciated.

The database is postgres. The associated file content is mentioned below


Last edited by Lansingli on Tue Nov 08, 2011 3:22 am, edited 4 times in total.

Top
 Profile  
 
 Post subject: Re: collection foreign key mapping has wrong number of columns:
PostPosted: Tue Nov 08, 2011 3:19 am 
Newbie

Joined: Tue Nov 08, 2011 3:13 am
Posts: 4
package com.nd.core.users.impl;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Product {
private String serialNumber;
private String name;

private Map parts = new HashMap();

public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Map getParts() { return parts; }
void setParts(Map parts) { this.parts = parts; }
public String getSerialNumber() { return serialNumber; }
void setSerialNumber(String sn) { serialNumber = sn; }
}


Top
 Profile  
 
 Post subject: Re: Foreign key (FK185958CF49BEAA68:PRODUCT [SERIALNUMBER])) mus
PostPosted: Tue Nov 08, 2011 3:20 am 
Newbie

Joined: Tue Nov 08, 2011 3:13 am
Posts: 4
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Nov 7, 2011 11:19:23 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.nd.core.users.impl.Product" table="PRODUCT">
<id name="serialNumber" type="java.lang.String">
<column name="SERIALNUMBER" />
<generator class="assigned" />
</id>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<map name="parts" table="PRODUCT" lazy="true">
<key>
<column name="SERIALNUMBER" />
</key>
<map-key type="string"></map-key>
<element type="string">
<column name="PARTS" />
</element>
</map>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Foreign key must have same number of columns as the referenc
PostPosted: Tue Nov 08, 2011 3:33 am 
Newbie

Joined: Tue Nov 08, 2011 3:13 am
Posts: 4
It got resolved when I changed the table name to PRODUCT_


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.