Hello,
I'm currently upgrading from xdoclet1.2.1 to xdoclet2.
I am having problems with the hibernate 'Component'
mapping generation. I'll begin with my understanding
of how I thought this worked in xdoclet1 and how I am
now having trouble making the same thing work in
xdoclet2 (please tell me If i'm talking complete
rubbish)...
The scenario I have is along these lines. I a top
level pojo class with xdoclet tags for a subcomponent
to be included. The java subcomponent is an interface
that has a corresponding 'impl' class. The impl class
is the one containing the Component properties to be
included in the hbm.xml file.
E.g.
package org.xdoclet.plugin.hibernate.pojo;
import java.util.Date;
/**
* test pojo to test primitive properties and ID
*
* @hibernate.class table="component-table"
*/
public class ComponentMapping {
/**
* @hibernate.component prefix="p"
*/
public AnotherClass classComponent;
/**
* @hibernate.component
*/
public Simple field;
/**
* @hibernate.id generator-class="native"
*/
private Long id;
private MyComponent myComponent;
/**
* @hibernate.component class="foo.bar.Baz"
update="false" insert="true"
* @hibernate.meta attribute="blurge" value="bang"
*/
public Simple getComponent() {
return field;
}
/**
* @hibernate.component class="foo.bar.Baz"
prefix="prfx_"
*/
public Simple getPrefixedComponent() {
return field;
}
/**
* @hibernate.property column="removed_dttm"
not-null="true"
*/
public Date getRemovedDttm() {
return null;
}
/**
* @hibernate.component
class="org.xdoclet.plugin.hibernate.pojo.MyComponentImpl"
*/
public MyComponent getMyComponent() {
return myComponent;
}
public class AnotherClass {
/**
* @hibernate.property
* @hibernate.column name="one"
*/
String stringField;
}
public class Simple {
/**
* @hibernate.parent
*/
ComponentMapping xyz;
/**
* @hibernate.property column="col"
access="field"
*/
String foo;
/**
* @hibernate.component prefix="nested_"
*/
Nested nested;
}
public class Nested {
/**
* @hibernate.property column="col"
*/
String go;
}
}
where the property is 'myProperty' is using the
'class' attribute to tell xdoclet where the impl is so
it can do its stuff:
@hibernate.component
class="org.xdoclet.plugin.hibernate.pojo.MyComponentImpl"
and where 'MyComponent' is the Interface which is
implemented by :
package org.xdoclet.plugin.hibernate.pojo;
public class MyComponentImpl implements MyComponent {
/**
* @hibernate.property column = "MY_COL"
*/
public String getSomeProp() {
return null;
}
}
what used to happen is that xdoclet1 used to look up
'MyComponentImpl' and then get properties from there.
Whereas now it just seems to lookup 'MyComponent' for
its mappings. I was expecting something like this to
be generated:
<component name="myComponent"
class="org.xdoclet.plugin.hibernate.pojo.MyComponentImpl">
<property name="someProp" column="MY_COL"/>
</component>
I have checked out the source from sf and had a look
at the Component.jelly file. Instead of just looking
at the props of 'property.type.javaClass' could it do
something along the line of this instead? :
<j:choose>
<j:when test="${componentTag.class_ != null}">
<j:set var="propsClazz"
value="${plugin.getMetadata(componentTag.class_)}"/>
</j:when>
<j:otherwise>
<j:set var="propsClazz"
value="${property.type.javaClass}"/>
</j:otherwise>
</j:choose>
<j:forEach var="property"
items="${plugin.getClassProperties(propsClazz)}">
<j:import uri="/HibernateProperties.jelly"
inherit="true"/>
</j:forEach>
Am I missing something? Is it supposed to work like
this for a reason? Any feedback would be much
appreciated :-)
Many Thanks,
Ron Tomlinson
___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail
http://uk.messenger.yahoo.com