Message:

  A new issue has been created in JIRA.

---------------------------------------------------------------------
View the issue:
  http://opensource.atlassian.com/projects/xdoclet/browse/XDT-1466

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XDT-1466
    Summary: Problem with inner class id-type
       Type: Bug

     Status: Open
   Priority: Major

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: XDoclet
 Components: 
             Hibernate Module
   Versions:
             1.3

   Assignee: xdoclet-devel (Use for new issues)
   Reporter: Joerg

    Created: Mon, 11 Jul 2005 7:12 AM
    Updated: Mon, 11 Jul 2005 7:12 AM
Environment: Linux

Description:
When I try to use a static inner class as type for the hibernate id like this:

------------------------------------------------------------------------------

/**
 * @hibernate.class table="my_table"
 */
public class MyClass implements Serializable {

    private static final long serialVersionUID = 1L;

    public static class Id extends IdBase {
        private static final long serialVersionUID = 1L;
        public Id( Long id) { super(id);}
    }

    public static class IdGenerator extends SequenceGenerator implements 
IdentifierGenerator {

        @Override
        public void configure( Type arg0, Properties props, Dialect dialect) 
throws MappingException {
            // Wir überschreiben die Configure-Methode und setzen als Typ einen 
Long
            super.configure( new LongType(), props, dialect);
        }

        @Override
        public Serializable generate( SessionImplementor arg0, Object arg1) 
throws HibernateException {
            Id tmp= new Id( (Long)super.generate( arg0, arg1));
            return tmp;
        }
        }

    public static class IdType extends IdTypeBase {

        @Override
        public Id createIdInstance(Long id) {
            return new Id( id);
        }

        @Override
        public Class returnedClass() {
            return Id.class;
        }

    }


    private Id  _id;
    private String  _name;

    /**
     * @hibernate.id
     *  type="MyClass$IdType"
     *  generator-class="MyClass$IdGenerator"
     *  column="id"
     * @hibernate.generator-param name="sequence" value="SEQ_my_table"
     */
    public Id getId() {
        return _id;
    }

    public void setId( Id id) {
        _id= id;
    }
        
    /**
     * @hibernate.property
     */
    public String getName() {
        return _name;
    }

    public void setName(String name) {
        _name = name;
    }
        
}

------------------------------------------------------------------------------

then I get the error message:

------------------------------------------------------------------------------

[hibernatedoclet] Caused by: xdoclet.XDocletException: Composite ID property of 
type MyClass$IdType is invalid. It has to be serializable and reimplement 
equals(Object)
[hibernatedoclet]       at 
xdoclet.modules.hibernate.HibernateTagsHandler.hasCompositeId_Impl(HibernateTagsHandler.java:732)
[hibernatedoclet]       at 
xdoclet.modules.hibernate.HibernateTagsHandler.ifHasCompositeId(HibernateTagsHandler.java:198)
[hibernatedoclet]       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
[hibernatedoclet]       at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[hibernatedoclet]       at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[hibernatedoclet]       at java.lang.reflect.Method.invoke(Method.java:585)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.invoke(TemplateEngine.java:641)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.invokeMethod(TemplateEngine.java:567)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.invokeBlockMethod(TemplateEngine.java:965)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.handleBlockTag(TemplateEngine.java:932)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.handleTag(TemplateEngine.java:472)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.generate(TemplateEngine.java:348)
[hibernatedoclet]       at 
xdoclet.XDocletTagSupport.generate(XDocletTagSupport.java:743)
[hibernatedoclet]       at 
xdoclet.tagshandler.ClassTagsHandler.ifHasClassTag(ClassTagsHandler.java:440)
[hibernatedoclet]       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method)
[hibernatedoclet]       at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[hibernatedoclet]       at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[hibernatedoclet]       at java.lang.reflect.Method.invoke(Method.java:585)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.invoke(TemplateEngine.java:641)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.invokeMethod(TemplateEngine.java:540)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.invokeBlockMethod(TemplateEngine.java:965)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.handleBlockTag(TemplateEngine.java:932)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.handleTag(TemplateEngine.java:472)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.generate(TemplateEngine.java:348)
[hibernatedoclet]       at 
xdoclet.template.TemplateEngine.start(TemplateEngine.java:415)
[hibernatedoclet]       at 
xdoclet.TemplateSubTask.startEngine(TemplateSubTask.java:573)
[hibernatedoclet]       at 
xdoclet.TemplateSubTask.generateForClass(TemplateSubTask.java:802)
[hibernatedoclet]       at 
xdoclet.TemplateSubTask.startProcessPerClass(TemplateSubTask.java:690)
[hibernatedoclet]       at 
xdoclet.TemplateSubTask.startProcess(TemplateSubTask.java:607)
[hibernatedoclet]       at xdoclet.XmlSubTask.startProcess(XmlSubTask.java:227)
[hibernatedoclet]       at 
xdoclet.modules.hibernate.HibernateSubTask.execute(HibernateSubTask.java:136)
[hibernatedoclet]       at xdoclet.XDocletMain.start(XDocletMain.java:49)
[hibernatedoclet]       at xdoclet.DocletTask.start(DocletTask.java:468)

------------------------------------------------------------------------------

When I change 


generator-class="MyClass$IdGenerator" 

in

generator-class="MyClass.IdGenerator" 

then everything is O.K. for xdoclet but hibernate doesn't like this very much.

I tested everything with a seperate .hbm.xml file ad it worked fine. 
Now I need to integrate my files in the build-system of the rest of the 
project, which works with xdoclet, and this Problem occured.

I also found no merge-point in the templates which let me specify my id-tag in 
a plain merge-file.




---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/xdoclet/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
xdoclet-devel mailing list
xdoclet-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to