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.  [ 2 posts ] 
Author Message
 Post subject: How to map an Interface as component
PostPosted: Tue Apr 04, 2006 2:39 pm 
Newbie

Joined: Tue Apr 04, 2006 2:28 pm
Posts: 1
In one of our HBM file I need to map an interface as component.

E.g.

If I have interface like this:

public interface Products
{
String getData();
setData(String s);
}

public class A
{
Products _products;

public void setProducts(Products products)
{
this._products=products;
}

public Products getProducts()
{
return _products.
}
}

In HBM File

<class name="A
table="Sample">
<component name="products">
<property name="data" type="java.lang.String"/>
</component>
</class>

If I try to load the above set it throws me an exception:

org.springframework.orm.hibernate.HibernateSystemException: Could not instantiate component with CGLIB: Products; nested exception is net.sf.hibernate.InstantiationException: Could not instantiate component with CGLIB:


Which is correct but is there any solution to build it ?


Top
 Profile  
 
 Post subject: Re: How to map an Interface as component
PostPosted: Tue Apr 04, 2006 5:20 pm 
Beginner
Beginner

Joined: Fri Mar 17, 2006 7:30 pm
Posts: 32
amardeepsingh wrote:
In one of our HBM file I need to map an interface as component.

E.g.

If I have interface like this:

public interface Products
{
String getData();
setData(String s);
}

public class A
{
Products _products;

public void setProducts(Products products)
{
this._products=products;
}

public Products getProducts()
{
return _products.
}
}

In HBM File

<class name="A
table="Sample">
<component name="products">
<property name="data" type="java.lang.String"/>
</component>
</class>

If I try to load the above set it throws me an exception:

org.springframework.orm.hibernate.HibernateSystemException: Could not instantiate component with CGLIB: Products; nested exception is net.sf.hibernate.InstantiationException: Could not instantiate component with CGLIB:


Which is correct but is there any solution to build it ?


Did you try setting the class attribute of the component tag to the interface? Something like:

Code:
<class name="A" table="Sample">
  <component name="products" class="Products">
    <property name="data" type="java.lang.String"/>
  </component>   
</class>


Btw, if the XML you posted is accurate to your file, there is a missing closing double quote on the name="A portion.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.