Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Problem generating metamodel

Interesting, if you add access=FIELD to the entity specification, that is,
<entity class="UserGroupList" name="UserGroupList" access=FIELD>
You still get the exception? I'm wondering if the @Override annotations are causing an invalid property access and invalid persistence mapping detection. Could be a bug here.

Cheers,
Guy

On 19/04/2010 1:05 PM, gjanjana wrote:
Thanks Guy for the response. Here is the class I have. Everything is mapped
through orm.xml, no annotations in the code. Attaching the snippet of
orm.xml as well.

--------------------------------------------
	<entity class="UserGroupList" name="UserGroupList">
		<table name="UserGroupList">
		</table>
		<attributes>
		    <id name="id" />
			<basic name="operation" />
			<basic name="groupIds" />
			<element-collection name="userNames">
				<collection-table
name="Acl_Users"></collection-table></element-collection>
		</attributes>
	</entity>


--------------------------------
public class UserGroupList implements UserGroupListAclConfig {

    /** Static logger reference. */
    private static final Logger LOGGER = LogFactory.getLogger();

    private List<String> groupIds = new ArrayList<String>();

    private List<String> userNames = new ArrayList<String>();

    private String operation;

    private String id;

    /** {@inheritDoc} */
    @Override
    
     public void addGroup(Group group) {
        if (!groupIds.contains(group.getId())) {
            groupIds.add(group.getId());
        }
    }

    /** {@inheritDoc} */
    @Override
    public void addUser(User user) {
        if (!userNames.contains(user.getName())) {
            userNames.add(user.getName());
        }
    }

    private List<String> getGroupIds() {
        return groupIds;
    }

    /** {@inheritDoc} */
    @Override
    public List<Group> getGroups() {
        GroupFactory factory = GroupFactory.getFactory();
        List<Group> groups = new ArrayList<Group>();
        for (String groupId : groupIds) {
            Group group = factory.getGroupById(groupId);
            if (group != null) {
                groups.add(group);
            }
        }
        return groups;
    }

    /**
     * Returns the id.
     * @return - String object
     */
    public String getId() {
        return id;
    }

    /** {@inheritDoc} */
    @Override
    public String getOperation() {
        return operation;
    }

    private List<String> getUserNames() {
        return userNames;
    }

    /** {@inheritDoc} */
    @Override
    public List<User> getUsers() {
        UserFactory factory = UserFactory.getFactory();
        List<User> users = new ArrayList<User>();
        for (String userName : userNames) {
            User user = factory.getUser(userName);
            if (user != null) {
                users.add(user);
            }
        }
        return users;
    }

    public void removeGroup(Group group) {
        groupIds.remove(group.getId());
    }

    public void removeUser(User user) {
        userNames.remove(user.getName());
    }

    private void setGroupIds(List<String> groupIds) {
        this.groupIds = groupIds;
    }

    /**
     * Sets the id to be used with AclConfig.
     * @param id
     */
    public void setId(String id) {
        this.id = id;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }

    private void setUserNames(List<String> userNames) {
        this.userNames = userNames;
    }
}
---------------------------------------------

Thanks,
gopal


gjanjana wrote:
  
Just posting this as a separate thread.

When I am running Metamodel APT either through commandline or through
eclipse APT, I am getting following error. My entity access type is set to
"Field" explicitly, not sure why preprocessor is trying to introspect the
methods. Any light on this is aprreciated.

"Mapping metadata cannot be applied to properties/methods that take
arguments. The attribute [method addGroup] from class [class
UserGroupList] is in violation of this restriction. Ensure the method has
no arguments if it is mapped with annotations or in an XML mapping file."

I have class userGroupList which is an entity with access type set to
"Field" not "Property", not sure why is it trying to validate methods. I
do have method addGroup in that class but it is just a business method 
that EclipseLink need not worry.

For your reference, this is how I try to generate the metadata information
using Ant:
------------------------------------------------------
  <target name="generate-metamodel" >
        <property name="metaPackage" value="metamodel"/>
        <delete>
            <fileset dir="${project.dir}/src"  includes="**/*_.java"/>
        </delete>
       <echo message="generating MetaData "/>
       <javac   srcdir="${project.dir}/src" verbose="true"
            destdir="${project.dir}/src"
            classpathref="compile.class.path">
              <compilerarg line=" -processor
org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor" />
              <compilerarg line=" -proc:only" compiler="javac1.6" />  
        </javac>

</target>
------------------------------------------------------


-gopal 

    
  

Back to the top