[This is a repost with additional detail and a partial solution.]
I'm trying to make a really quick change to xdoclet so that we can move
away from frequently using merge files.
Here's a simple example of a class which contains two of the same
components. I'm using hibernate 2.01 and xdoclet 1.2b3.
Given a basic class, PhoneNumber:
package com.le.examples.hibernate;
public class PhoneNumber {
/** @hibernate.property */
public String getNumber() { return number; }
public void setNumber(String number) { this.number = number; }
/** @hibernate.property */
public String getExtension() { return extension; }
public void setExtension(String extension) { this.extension = extension; }
private String number;
private String extension;
}
And a simple class Person:
package com.le.examples.hibernate;
/** @hibernate.class table="person" */
public class Person {
public Person() {}
/** @hibernate.id generator-class="native" */
public long getId() { return id; }
public void setId(long id) { this.id = id; }
/** @hibernate.component */
public PhoneNumber getHomeNumber() { return homeNumber; }
public void setHomeNumber(PhoneNumber homeNumber) { this.homeNumber = homeNumber; }
/** @hibernate.component */
public PhoneNumber getWorkNumber() { return workNumber; }
public void setWorkNumber(PhoneNumber workNumber) { this.workNumber = workNumber; }
private long id;
private PhoneNumber homeNumber;
private PhoneNumber workNumber;
}
The following schema is generated (mysql):
create table person (
id BIGINT NOT NULL AUTO_INCREMENT,
number VARCHAR(255),
extension VARCHAR(255),
primary key (id)
)
The problem is that the second phone number component is lost. It's listed
in the xdoclet generated hibernate mapping, but with column names that
repeat (are non-unique).
I'd like to add a parameter to the @hibernate.component tag called
column-prefix. This would simply prefix the column names with whatever
text you specify. In the above example one might use column-prefixs of
"home_" and "work_" so that the two components can be differentiated.
I started hacking the hibernate .xdt files and I'm stuck. I can hardcode
prefixes, but I can't figure out the query to get the actually value of
column-prefix defined at the @hibernate.component level. Here's the line
I'm stuck on in the hibernate-column.xdt file... this is my modified
version:
column="<XDtMethod:methodTagValue tagName="<XDtHibernate:getCurrentTag/>"
paramName="column-prefix" default=""/><XDtMethod:methodTagValue
tagName="<XDtHibernate:getCurrentTag/>" paramName="column"
default="<XDtMethod:propertyName/>"/>"
I want the first part to return the value of the column-prefix... but it's
always blank? What am I doing wrong and how can I get to return the right
value?
Thanks,
Christian
PS: I have updated the xtags.xml document as well.
---------------------------------------------------------------------------
Christian 'xian' Nelson [EMAIL PROTECTED]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Don't ask yourself what the world needs. Ask yourself what makes
you come alive, and go do that, because what the world needs is people
who have come alive." -- Howard Thurman
---------------------------------------------------------------------------
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user