[
https://jira.jboss.org/jira/browse/JBSEAM-3278?page=com.atlassian.jira.pl...
]
Julien Kronegg commented on JBSEAM-3278:
----------------------------------------
Occurs at least under Seam 2.0.0.GA when the package name is specified in the
seam-gen.reveng.xml file: <table-filter name-filter="XXX"
package="my.package"/>
There is a "patch" (better than proposed in the associated forum thread, I
think):
In the {SEAMHOME}/seam-gen/src/EntityHome.java.ftl, replace the following strings:
1) line 74: ${parentPojo.shortName}
${property.name}=${parentHomeName}.getDefinedInstance();
must be replaced by:
<#if parentPojo.packageName !=
"">${pojo.importType("${parentPojo.packageName}.${parentPojo.shortName}")}<#else>${parentPojo.shortName}</#if>
${property.name}=${parentHomeName}.getDefinedInstance();
2) line 104: public
${pojo.importType("java.util.List")}<${childPojo.shortName}> ${getter}()
{
must be replaced by:
public ${pojo.importType("java.util.List")}<<#if childPojo.packageName
!=
"">${pojo.importType("${childPojo.packageName}.${childPojo.shortName}")}<#else>${childPojo.shortName}</#if>>
${getter}() {
IMHO, this "patch" is better than the ones proposed in the forum thread because
it imports the missing classes.
The only use case which is does not work is if an EntityHome in a package "A"
uses a class without package: there will be no import but the class will not compile
because the class cannot be found. However, this use cases seems to be not planned in the
Java specification (see
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4361575).
Moreover, using a class without package name is discouraged by best practices.
seam-gen generate-ui problem - entity in a different package
-------------------------------------------------------------
Key: JBSEAM-3278
URL:
https://jira.jboss.org/jira/browse/JBSEAM-3278
Project: Seam
Issue Type: Bug
Components: Tools
Reporter: Guido Simone
Here is an example:
The entity class PersonAddress has a ManyToOne relationship with Address which happens to
be in a different package. The seam generate-ui command will generate (among other
things) an EntityHome class named PersonAddressHome.
//==================================
// PersonAddress
package com.domain.model.person;
import com.domain.model.location.Address;
@Entity
public class PersonAddress
{
private Address address;
private PersonAddressTypeLookup addressTypeLookup;
private Person person;
@ManyToOne @NotNull
public Address getAddress() {return address;}
@ManyToOne @NotNull
public PersonAddressTypeLookup getAddressTypeLookup()
{ return addressTypeLookup; }
@ManyToOne @NotNull
public Person getPerson() {return person;}
// setters omitted
}
which generates:
//==================================
// PersonAddressHome
package com.domain.action;
import com.domain.model.person.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;
@Name("personAddressHome")
public class PersonAddressHome extends EntityHome<PersonAddress>
{
// code omitted...
public void wire()
{
getInstance();
Address address = addressHome.getDefinedInstance();
if (address != null)
{
getInstance().setAddress(address);
}
PersonAddressTypeLookup addressTypeLookup = addressTypeLookupHome
.getDefinedInstance();
if (addressTypeLookup != null)
{
getInstance().setAddressTypeLookup(addressTypeLookup);
}
Person person = personHome.getDefinedInstance();
if (person != null)
{
getInstance().setPerson(person);
}
}
The generated code imports all entities in com.domain.model.person, but does not import
anything from com.domain.model.location so the compilation fails in the second line of the
wire() method (Address cannot be resolved to a type).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira