-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: composite-element Could not resolve type for composite-el...
PostPosted: Thu Nov 17, 2005 5:14 am 
Beginner
Beginner

Joined: Mon Jan 24, 2005 11:56 am
Posts: 24
Hi,

We are using below mapping file and try to run hbm2java command on it

Code:
<hibernate-mapping package="sample">
   <class name="Employee" table="employee">
      <id name="id" type="long" length="12">
         <generator class="increment"></generator>
      </id>
      <property name="taxFileNumber" type="string" />
      <set name="fullname" table="Names">
         <key column="id" />
         <composite-element class="Fullname">         
              <property name="firstName" type="string" />
              <property name="lastName" type="string" />
         </composite-element>       
         </set>
   </class>

</hibernate-mapping>

An error accours which says "Could not resolve type without Exception" for property "fullname"

The error is
Code:
org.hibernate.tool.hbm2x.ExporterException: MethodInvocationException while processing template Pojo. Invocation of method 'get' in 
class org.hibernate.tool.hbm2x.TemplateHelper$Templates threw exception class org.hibernate.tool.hbm2x.ExporterException : MethodInvocationException while processing template pojo/PojoFields.vm. Invocation of method 'getJavaTypeName' in 
class org.hibernate.tool.hbm2x.Cfg2JavaTool threw exception class org.hibernate.tool.hbm2x.ExporterException :
Could not resolve type without exception for org.hibernate.mapping.Property(fullname) Value: org.hibernate.mapping.Set(sample.Employee.fullname)


Regards,
Alireza Fattahi


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 12:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
please check with the latest CVS version if it still occurs there.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: error still occurs with jdk5="true"
PostPosted: Mon Feb 27, 2006 9:51 am 
Newbie

Joined: Mon Feb 27, 2006 9:26 am
Posts: 2
Location: Germany
I tried exactly the same mapping file from above with tools 3.1.0-beta4. It works if "jdk5" is set to "false" in the hbm2java task, but fails, if it set to true.

Code:
<hibernatetool destdir="${generated.sources.dir}">
    <configuration configurationfile="${resources.dir}/hibernate.cfg.xml"/>
        <hbm2java jdk5="true"/>
</hibernatetool>


I just tried the current CVS (Hibernate3 and HibernateExt) and got this exception:

Code:
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(Employee)
   at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
   at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Expression.getStringValue(Expression.java:93)
   at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
   at freemarker.core.Environment.visit(Environment.java:351)
   at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.include(Environment.java:1375)
   at freemarker.core.Include.accept(Include.java:155)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.IfBlock.accept(IfBlock.java:82)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.visit(Environment.java:233)
   at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.process(Environment.java:176)
   at freemarker.template.Template.process(Template.java:231)
   at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:243)
   ... 28 more
Caused by: org.hibernate.tool.hbm2x.ExporterException: Could not resolve type without exception for org.hibernate.mapping.Property(fullname) Value: org.hibernate.mapping.Set(Employee.fullname)
   at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:270)
   at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:171)
   at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(BasicPOJOClass.java:631)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:583)
   at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
   ... 60 more
Caused by: org.hibernate.MappingException: component class not found: Fullname
   at org.hibernate.mapping.Component.getComponentClass(Component.java:105)
   at org.hibernate.tuple.PojoComponentTuplizer.buildGetter(PojoComponentTuplizer.java:116)
   at org.hibernate.tuple.AbstractComponentTuplizer.<init>(AbstractComponentTuplizer.java:39)
   at org.hibernate.tuple.PojoComponentTuplizer.<init>(PojoComponentTuplizer.java:28)
   at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:126)
   at org.hibernate.mapping.Component.getType(Component.java:160)
   at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:320)
   at org.hibernate.tool.hbm2x.Cfg2JavaTool.getGenericCollectionDeclaration(Cfg2JavaTool.java:277)
   at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:254)
   ... 68 more
Caused by: java.lang.ClassNotFoundException: Fullname
   at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1166)
   at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1107)
   at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:977)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
   at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:164)
   at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
   at org.hibernate.mapping.Component.getComponentClass(Component.java:102)
   ... 76 more



Regards,

Sven


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 11:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well beta4 is not equal to cvs is it ? :)

anyway, i just confirmed this to be an issue and fixed it....just not committed yet since we are in a cvs to svn move at the moment.

will commit when that is ready

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 12:28 pm 
Newbie

Joined: Mon Feb 27, 2006 9:26 am
Posts: 2
Location: Germany
I meant, I had the same problem as the OP in beta-4 and after that tried CVS HEAD also, just to avoid being flamed (have read the "How To Ask For Help" carefully) ;-)

Thanks a lot for the quick response.

Actually my original mapping did not contain a composite-element in a set, but in a list:

Code:
<hibernate-mapping>

    <class name="Invoice" table="INVOICES">
        <id name="id" column="INVOICE_ID" type="long">
            <meta attribute="scope-set">protected</meta>
            <generator class="native"/>
        </id>
        <property name="invoiceDate" type="date" not-null="true"/>
        <list name="entries" table="INVOICE_ENTRIES">
            <key column="INVOICE_ID"/>
            <list-index column="POSITION"/>
            <composite-element class="InvoicePosition">
                <property name="description" type="string"/>
                <property name="amount" type="double"/>
            </composite-element>
        </list>
    </class>

</hibernate-mapping>


I assume, the fix is for both cases?

By the way, I tried the hbm2ddl task with the Invoice mapping from above and got these output and exceptions:

Code:
    create table INVOICES (
        INVOICE_ID bigint generated by default as identity (start with 1),
        invoiceDate date not null,
        primary key (INVOICE_ID)
    );

    create table INVOICE_ENTRIES (
        INVOICE_ID bigint not null,
        description varchar(255),
        amount double,
        POSITION integer not null,
        primary key (INVOICE_ID, POSITION)
    );

    alter table INVOICE_ENTRIES
        add constraint FKA45A293E4A039E7A
        foreign key (INVOICE_ID)
        references INVOICES;
3 errors occurred while performing <hbm2ddl>.
Error #1: java.sql.SQLException: Table already exists: INVOICES in statement [create table INVOICES]
Error #1: java.sql.SQLException: Unexpected token: POSITION in statement [create table INVOICE_ENTRIES (INVOICE_ID bigint not null, description varchar(255), amount double, POSITION]
Error #1: java.sql.SQLException: Table not found: INVOICE_ENTRIES in statement [alter table INVOICE_ENTRIES]


The generated schema looks OK to me, however.

Best regards,

Sven


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 2:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes it was a general problem for composite-element when you wanted to generate List<compositeelementclassname>

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.