Iam Getting following exception
net.sf.hibernate.MappingException: Repeated column in mapping for collection: com.liferay.portal.ejb.UserHBM.groups column: portalId
Mine Is Hibernate Version 2,Oracle 9i
One Part of code is below
session = HibernateUtil.openSession();
StringBuffer query = new StringBuffer();
query.append("SELECT COUNT(*) FROM ");
query.append(com.liferay.portal.ejb.UserHBM.class.getName());
query.append(" userHBM ");
query.append("JOIN userHBM.groups AS groupHBM ");
query.append("WHERE userHBM.userId = ? ").append(" AND ");
query.append("userHBM.portalId = ? ");
String pk1 = userPK.userId;
String pk2 = userPK.portalId;
Object[] values = { pk1, pk2 };
Type[] types = { Hibernate.STRING, Hibernate.STRING };
return ((Integer)session.iterate(query.toString(), values, types)
.next()).intValue();
HibernateUtil.closeSession(session);
Below is the table and mapping structure<class name="com.liferay.portal.ejb.UserHBM" table="TCPS_User_">
<composite-id name="primaryKey" class="com.liferay.portal.ejb.UserPK">
<key-property name="userId"/>
<key-property name="portalId"/>
</composite-id>
<property name="emailAddress"/>
<property name="languageId"/>
<property name="timeZoneId"/>
<property name="skinId"/>
<property name="dottedSkins" type="com.liferay.util.dao.hibernate.BooleanType"/>
<property name="roundedSkins" type="com.liferay.util.dao.hibernate.BooleanType"/>
<property name="greeting"/>
<property name="resolution"/>
<property name="refreshRate"/>
<property name="layoutIds"/>
<property name="loginDate"/>
<property name="loginIP"/>
<property name="lastLoginDate"/>
<property name="lastLoginIP"/>
<set name="groups" table="Users_Groups" lazy="true"> <key> <column name="userId"/> <column name="portalId"/> </key> <many-to-many class="com.liferay.portal.ejb.GroupHBM"> <column name="groupId"/> <column name="portalId"/> </many-to-many> </set></class>
<class name="com.liferay.portal.ejb.GroupHBM" table="TCPS_Group_">
<composite-id name="primaryKey" class="com.liferay.portal.ejb.GroupPK">
<key-property name="groupId"/>
<key-property name="portalId"/>
</composite-id>
<property name="parentGroupId"/>
<property name="name"/>
<property name="layoutIds"/>
<property name="wikiNodeIds"/>
<set name="users" table="Users_Groups" lazy="true"> <key> <column name="groupId"/> <column name="portalId"/> </key> <many-to-many class="com.liferay.portal.ejb.UserHBM"> <column name="userId"/> <column name="portalId"/> </many-to-many> </set>
</class>
Table Structure
---------------
CREATE TABLE TCPS_USER_ (
USERID VARCHAR2 (100) NOT NULL,
PORTALID VARCHAR2 (100) NOT NULL,
EMAILADDRESS VARCHAR2 (100),
LANGUAGEID VARCHAR2 (10) DEFAULT '',
TIMEZONEID VARCHAR2 (30) DEFAULT '',
SKINID VARCHAR2 (100) DEFAULT '1',
DOTTEDSKINS NUMBER (1) DEFAULT '0',
ROUNDEDSKINS NUMBER (1) DEFAULT '0',
GREETING VARCHAR2 (100) DEFAULT '',
RESOLUTION VARCHAR2 (100) DEFAULT '',
REFRESHRATE VARCHAR2 (100) DEFAULT '',
LAYOUTIDS VARCHAR2 (100) DEFAULT '',
LOGINDATE DATE,
LOGINIP VARCHAR2 (100) DEFAULT '',
LASTLOGINDATE DATE,
LASTLOGINIP VARCHAR2 (100) DEFAULT '',
FIRSTNAME VARCHAR2 (100),
MIDDLENAME VARCHAR2 (100),
LASTNAME VARCHAR2 (100),
PRIMARY KEY ( USERID, PORTALID )
CREATE TABLE TCPS_USERS_GROUPS ( USERID VARCHAR2 (100) NOT NULL, GROUPID VARCHAR2 (100) NOT NULL, PORTALID VARCHAR2 (100) NOT NULL, CONSTRAINT PK_TCPS_USERS_GROUPS PRIMARY KEY ( USERID, GROUPID, PORTALID )
ALTER TABLE TCPS_USERS_GROUPS ADD CONSTRAINT FK1 FOREIGN KEY (GROUPID, PORTALID) REFERENCES CPSUSER.TCPS_GROUP_ (GROUPID, PORTALID) ;
ALTER TABLE TCPS_USERS_GROUPS ADD CONSTRAINT FK2 FOREIGN KEY (USERID, PORTALID) REFERENCES CPSUSER.TCPS_USER_ (USERID, PORTALID) ;
CREATE TABLE TCPS_GROUP_ (
GROUPID VARCHAR2 (100) NOT NULL,
PORTALID VARCHAR2 (100) NOT NULL,
PARENTGROUPID VARCHAR2 (100),
NAME VARCHAR2 (100),
LAYOUTIDS VARCHAR2 (100) DEFAULT '',
WIKINODEIDS VARCHAR2 (100) DEFAULT '',
PRIMARY KEY ( GROUPID, PORTALID )
|