Hi All,
I am facing problem while using Map Object in Hibernate.
I have following 3 tables:
mysql> desc DefaultPropertyAV;
+--------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+------------------+------+-----+---------+----------------+
| defaultPropertyAVKey | int(11) unsigned | NO | PRI | | auto_increment |
| userKey | int(11) unsigned | NO | MUL | | |
| defaultPropertyAttribKey | int(11) unsigned | NO | MUL | | |
| defaultPropertyValueKey | int(11) unsigned | NO | MUL | | |
+--------------------------+------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
mysql> desc DefaultPropertyAttrib;
+--------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------------+------------------+------+-----+---------+----------------+
| defaultPropertyAttribKey | int(11) unsigned | NO | PRI | | auto_increment |
| attribName | varchar(255) | NO | | | |
+--------------------------+------------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql> desc DefaultPropertyValue;
+-------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------+------------------+------+-----+---------+----------------+
| defaultPropertyValueKey | int(11) unsigned | NO | PRI | | auto_increment |
| VALUE | varchar(255) | NO | | | |
+-------------------------+------------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
I need to add a map object in hbm file of DefaultPropertyAV table.
This map will contain key as "defaultPropertyAttribKey" of second table, and value as "defaultPropertyValueKey" of third table. But I am getting following exception while trying to run with above stuff:
org.hibernate.MappingException: Foreign key (FKC63599CB61F99016:DefaultPropertyAV [defaultPropertyAVKey])) must have same number of columns as the referenced primary key (DefaultPropertyAV [defaultPropertyAVKey,defaultPropertyAttribKey])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:86)
at org.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:51)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:976)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:921)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:800)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:726)
at ………..
IF ANYONE HAVE FACED SAME KIND OF PROBLEM, PLEASE GUIDE ME IF YOU HAVE ANY IDEA REGARDING THIS.
Thanks in Advance.
Regards,
Sachin Naik
India
|