Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3
Name and version of the database you are using: MySQL 4.1.9
I have the following two tables
user:
Fields include userId BIGINT and standard user type fields
userrole:
Fields include 
userRoleId BIGINT Primary (auto increment)
userId BIGINT index
roleId BIGINT index
I want the association of user to userrole to be one to many and use the following association mapping in user mapping file
<list name="roles" lazy="false" cascade="all-delete-orphan" inverse="true">
  <key column="userId"/>
  <list-index column="roleId"/>
  <one-to-many class="uk.co.acudev.valueobjects.UserRole" />
</list>
I originally didn't have a userRoleId in userrole (oversight) and before it was added my userrole mapping looked like
<?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 06-Feb-2008 18:50:58 by Hibernate Tools 3.2.0.CR1 -->
<hibernate-mapping>
    <class name="uk.co.acudev.valueobjects.UserRole" table="userrole" catalog="acudevcart">
        <id name="userId" type="java.lang.Long">
            <column name="userId" />
			<generator class="foreign">
				<param name="property">user</param>
			</generator>
        </id>
        <version name="version" type="long">
            <column name="version" not-null="true" />
        </version>        
        <property name="roleId" type="long">
            <column name="roleId" not-null="true" />
        </property>
        <many-to-one name="role" update="false" insert="false" lazy="false"
        	column="roleId" 
        	class="uk.co.acudev.valueobjects.Role" 
        	cascade="none" 
        	unique="true" 
        	not-null="false">
        </many-to-one>
        <many-to-one name="user" insert="false" update="false" not-null="true" 
        	column="userId" 
        	class="uk.co.acudev.valueobjects.User" >
        </many-to-one>
    </class>
</hibernate-mapping>
i now want to add the userRoleId as an id element instead of userId in the above mapping and therefore userId will become a standard property....
my question: is it still possible to have the userId as a foreign key thats updated with the userId from User when its been saved or do i have to turn cascading off, save user then manually assign its userId to userrole and save userrole ?
it would be nice to have the generator element in any property element.
thanks
adam