[jboss-user] [JBoss Seam] - Using stateless beans generated by seam in standalone Java a
JbossDing
do-not-reply at jboss.com
Thu Jul 12 10:36:15 EDT 2007
I am pretty new to seam framework but have 3 years experience with previous versions of EJB. Our project is using seam to generate codes for a web application to access backend database. It works pretty good. However, I have the need to access the same database in standalone Java applications outside of Jboss virtual machine. When I looked at the seam-generated code, I am lost and need help.
First how to look up session bean in my Java application? I can not find the ejb-jar.xml so I do not know what is the jndi name used for the generated beans. Second, I do not know how to call those generated beans. For example, I have a table called Host in a test database, the table is simple with id, hostname, and connect_time. Use seam setup, seam new-project, seam generate-entities, and seam explode, seam framework did almost everything for me. It generates two java files in the action folder. Here is the code: in HostList.java
@Name("hostList")
| public class HostList extends EntityQuery {
|
| private static final String[] RESTRICTIONS = {"lower(host.hostname) like concat(lower(#{hostList.host.hostname}),'%')",};
|
| private Host host = new Host();
|
| @Override
| public String getEjbql() {
| return "select host from Host host";
| }
|
| @Override
| public Integer getMaxResults() {
| return 25;
| }
|
| public Host getHost() {
| return host;
| }
|
| @Override
| public List<String> getRestrictions() {
| return Arrays.asList(RESTRICTIONS);
| }
|
| }
in HostHome.java
@Name("hostHome")
| public class HostHome extends EntityHome<Host> {
|
| public void setHostId(Integer id) {
| setId(id);
| }
|
| public Integer getHostId() {
| return (Integer) getId();
| }
|
| @Override
| protected Host createInstance() {
| Host host = new Host();
| return host;
| }
|
| public void wire() {
| }
|
| public boolean isWired() {
| return true;
| }
|
| public Host getDefinedInstance() {
| return isIdDefined() ? getInstance() : null;
| }
|
| }
By looking at the code, I am lost at how I should call the bean to make select, update, delete, and insert operations.
Would anyone give me some help or point me to some documents or tutorials? Thanks a lot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4063530#4063530
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4063530
More information about the jboss-user
mailing list