Hello,
I've a question about the CodeGenerator - I love it, I think it's great, the Finder generator is really cool - but....
I have a mapping file that declares a base superclass with a primary key and a single attribute - ObjectType - which is a <many-to-one> to an ObjectType Table. All other classes/tables are joined-subclasses. The problem is that this ObjectType is getting imported in all classes in this package - thereby causing compilation to fail. Is there any way I can prevent this from happening? I've considered changing the access attribute of the <many-to-one> for ObjectType to private, but I don't really like that solution (if it is in fact one). Here's a piece of the mapping file:
Code:
<hibernate-mapping package="org.wgbh.scape.domain" auto-import="false">
<class name="org.wgbh.scape.domain.UnidentifiedFoundationObject" optimistic-lock="dirty" polymorphism="explicit" table="OBJECT">
<meta attribute="class-description">
The UnidentifiedFoundationObject class is the base-class for all
objects within Scape. It is an abstract class.
@author Brian R. Wainwright
@version 1.0
</meta>
<meta attribute="scope-class" inherit="false">public abstract</meta>
<meta attribute="implements">org.wgbh.scape.Associable</meta>
<id column="OBJECT_ID" name="objectIID" type="string" unsaved-value="id_value">
<generator class="uuid.hex"/>
</id>
<property column="ACCESS_PRIVILEGE" insert="true" name="accessPrivilege"
type="string" update="true"/>
<many-to-one class="ObjectType" column="OBJECT_TYPE_ID" insert="true"
name="objectType" update="true">
<meta attribute="finder">findByObjectType</meta>
</many-to-one>
<joined-subclass name="org.wgbh.scape.domain.AccessGroup" table="ACCESS_GROUP">
<meta attribute="class-description">
@author Brian R. Wainwright
@version 1.0
</meta>
<key column="ACCESS_GROUP_ID"/>
<set name="objects" table="OBJECT_ACCESS_GROUP" lazy="true" outer-join="auto" batch-size="50" inverse="true">
<key column="ACCESS_GROUP_ID"/>
<many-to-many class="UnidentifiedFoundationObject" column="OBJECT_ID"/>
</set>
<property column="ACCESS_LEVEL" name="accessLevel" type="integer"/>
<property column="ACCESS_LEVEL_NAME" name="name" type="string">
<meta attribute="finder">findByAccessLevel</meta>
</property>
</joined-subclass>
</class>
</hibernate-mapping>
and some resulting code generated by the CodeGenerator:
Code:
package org.wgbh.scape.domain;
import ObjectType; //this line causes compilation to fail
import java.io.Serializable;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
*
* @author Brian R. Wainwright
* @version 1.0
*
*/
public class AccessGroup extends UnidentifiedFoundationObject implements org.wgbh.scape.Associable,Serializable {
/** nullable persistent field */
private int accessLevel;
/** nullable persistent field */
private String name;
/** persistent field */
private Set objects;
/** full constructor */
public AccessGroup(String accessPrivilege, ObjectType objectType, Set associatedObjects, Set associatedProjects, Set associations, Set comments, Set attributes, Set access, int accessLevel, String name, Set objects) {
super(accessPrivilege, objectType, associatedObjects, associatedProjects, associations, comments, attributes, access);
this.accessLevel = accessLevel;
this.name = name;
this.objects = objects;
}
Any help is appreciated. Thanks!