[
https://issues.jboss.org/browse/JDF-129?page=com.atlassian.jira.plugin.sy...
]
Hardy Ferentschik commented on JDF-129:
---------------------------------------
The project compiles before I run _admin_layer.fsh_ and fails to compile independent of
whether I install the patch:
{code}
package org.jboss.jdf.examples.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.ejb.Stateful;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.jboss.jdf.example.ticketmonster.model.SectionAllocation;
/**
* Backing bean for SectionAllocation entities.
* <p>
* This class provides CRUD functionality for all SectionAllocation entities. It focuses
* purely on Java EE 6 standards (e.g. <tt>@ConversationScoped</tt>
for
* state management, <tt>PersistenceContext</tt> for persistence,
* <tt>CriteriaBuilder</tt> for searches) rather than introducing a CRUD
framework or
* custom base class.
*/
@Named
@Stateful
@ConversationScoped
public class SectionAllocationBean implements Serializable
{
private static final long serialVersionUID = 1L;
/*
* Support creating and retrieving SectionAllocation entities
*/
private long id;
public long getId()
{
return this.id;
}
public void setId(long id)
{
this.id = id;
}
private SectionAllocation sectionAllocation;
public SectionAllocation getSectionAllocation()
{
return this.sectionAllocation;
}
@Inject
private Conversation conversation;
@PersistenceContext(type = PersistenceContextType.EXTENDED)
private EntityManager entityManager;
public String create()
{
this.conversation.begin();
return "create?faces-redirect=true";
}
public void retrieve()
{
if (FacesContext.getCurrentInstance().isPostback())
{
return;
}
if (this.conversation.isTransient())
{
this.conversation.begin();
}
if (this.id == null)
{
this.sectionAllocation = this.example;
}
else
{
this.sectionAllocation = findById(getId());
}
}
public SectionAllocation findById(long id)
{
return this.entityManager.find(SectionAllocation.class, id);
}
/*
* Support updating and deleting SectionAllocation entities
*/
public String update()
{
this.conversation.end();
try
{
if (this.id == null)
{
this.entityManager.persist(this.sectionAllocation);
return "search?faces-redirect=true";
}
else
{
this.entityManager.merge(this.sectionAllocation);
return "view?faces-redirect=true&id=" +
this.sectionAllocation.getId();
}
}
catch (Exception e)
{
FacesContext.getCurrentInstance().addMessage(null, new
FacesMessage(e.getMessage()));
return null;
}
}
public String delete()
{
this.conversation.end();
try
{
this.entityManager.remove(findById(getId()));
this.entityManager.flush();
return "search?faces-redirect=true";
}
catch (Exception e)
{
FacesContext.getCurrentInstance().addMessage(null, new
FacesMessage(e.getMessage()));
return null;
}
}
/*
* Support searching SectionAllocation entities with pagination
*/
private int page;
private long count;
private List<SectionAllocation> pageItems;
private SectionAllocation example = new SectionAllocation();
public int getPage()
{
return this.page;
}
public void setPage(int page)
{
this.page = page;
}
public int getPageSize()
{
return 10;
}
public SectionAllocation getExample()
{
return this.example;
}
public void setExample(SectionAllocation example)
{
this.example = example;
}
public void search()
{
this.page = 0;
}
public void paginate()
{
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
// Populate this.count
CriteriaQuery<Long> countCriteria = builder.createQuery(Long.class);
Root<SectionAllocation> root = countCriteria.from(SectionAllocation.class);
countCriteria =
countCriteria.select(builder.count(root)).where(getSearchPredicates(root));
this.count = this.entityManager.createQuery(countCriteria).getSingleResult();
// Populate this.pageItems
CriteriaQuery<SectionAllocation> criteria =
builder.createQuery(SectionAllocation.class);
root = criteria.from(SectionAllocation.class);
TypedQuery<SectionAllocation> query =
this.entityManager.createQuery(criteria.select(root).where(getSearchPredicates(root)));
query.setFirstResult(this.page * getPageSize()).setMaxResults(getPageSize());
this.pageItems = query.getResultList();
}
private Predicate[] getSearchPredicates(Root<SectionAllocation> root)
{
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
List<Predicate> predicatesList = new ArrayList<Predicate>();
return predicatesList.toArray(new Predicate[predicatesList.size()]);
}
public List<SectionAllocation> getPageItems()
{
return this.pageItems;
}
public long getCount()
{
return this.count;
}
/*
* Support listing and POSTing back SectionAllocation entities (e.g. from inside an
* HtmlSelectOneMenu)
*/
public List<SectionAllocation> getAll()
{
CriteriaQuery<SectionAllocation> criteria =
this.entityManager.getCriteriaBuilder().createQuery(SectionAllocation.class);
return
this.entityManager.createQuery(criteria.select(criteria.from(SectionAllocation.class))).getResultList();
}
@Resource
private SessionContext sessionContext;
public Converter getConverter() {
final SectionAllocationBean ejbProxy =
this.sessionContext.getBusinessObject(SectionAllocationBean.class);
return new Converter() {
@Override
public Object getAsObject(FacesContext context,
UIComponent component, String value) {
return ejbProxy.findById(long.valueOf(value));
}
@Override
public String getAsString(FacesContext context,
UIComponent component, Object value) {
if (value == null) {
return "";
}
return String.valueOf(((SectionAllocation)
value).getId());
}
};
}
return String.valueOf(((SectionAllocation)
value).getId());
}
};
}
/*
* Support adding children to bidirectional, one-to-many tables
*/
private SectionAllocation add = new SectionAllocation();
public SectionAllocation getAdd()
{
return this.add;
}
public SectionAllocation getAdded()
{
SectionAllocation added = this.add;
this.add = new SectionAllocation();
return added;
}
}
{code}
admin_layer.fsh modifies SectionAllocationBean in a way that it does
not compile
--------------------------------------------------------------------------------
Key: JDF-129
URL:
https://issues.jboss.org/browse/JDF-129
Project: JBoss Developer Framework
Issue Type: Feature Request
Components: ticket-monster
Reporter: Hardy Ferentschik
Assignee: Marius Bogoevici
Running _admin_layer.fsh_ without applying the patches modifies _SectionAllocationBean_
in a way that it does not compile:
{noformat}
[INFO] ------------------------------------------------------------------------
[INFO] Building ticket-monster 2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ ticket-monster ---
[INFO]
[INFO] --- gwt-maven-plugin:2.4.0:clean (gwt-clean) @ ticket-monster ---
[INFO] auto discovered modules [org.jboss.jdf.example.ticketmonster.BookingMonitor]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ ticket-monster ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO]
[INFO] --- gwt-maven-plugin:2.4.0:resources (default) @ ticket-monster ---
[INFO] auto discovered modules [org.jboss.jdf.example.ticketmonster.BookingMonitor]
[INFO] 26 source files from GWT module
org.jboss.jdf.example.ticketmonster.BookingMonitor
[INFO]
[INFO] --- maven-compiler-plugin:2.3.1:compile (default-compile) @ ticket-monster ---
[INFO] Compiling 62 source files to
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,34]
class expected
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,41]
')' expected
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,42]
not a statement
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,47]
';' expected
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.887s
[INFO] Finished at: Mon Oct 22 17:59:06 CEST 2012
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project
ticket-monster: Compilation failure: Compilation failure:
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,34]
class expected
[ERROR]
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,41]
')' expected
[ERROR]
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,42]
not a statement
[ERROR]
[ERROR]
/Users/hardy/work/hibernate/git/misc/ticket-monster/demo/src/main/java/org/jboss/jdf/examples/view/SectionAllocationBean.java:[262,47]
';' expected
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the
following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
***ERROR*** Exception encountered: Build failed. (type "set VERBOSE true" to
enable stack traces)
{noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira