[EJB 3.0] - Re: Need some help with mapping
by MikeDougherty
Thanks for your response Felix. But I'm not sure you are understanding the problem. I am not mapping Items in a store. I am mapping attributes *of* a store. If you look in the example code I posted, there is a Type of store. What is not in the post are other attributes like, Status, Region, etc. The possible values of these "types" is stored in the TYPE_TABLE.
Think of them as enumerated types, but rather than being hard coded in a class file, the types are kept in a database.
Also, note that I am mapping to a legacy system, so I have no control over the data model.
So to answer your questions:
* Yes, the TABLE_NAME is the name of the table that my Store object is mapped to. The only thing I am using it for at present is in the TypePK object to ensure uniqueness.
* Store does not extend Item. What I had was a StoreType extending Type. Not because I thought I needed a StoreType, but because it seemed the only way to map the Type object to the appropriate sub elements in the Type table.
* Also, I'm not sure @EmbeddedId and @Embeddable will work in this case. But feel free to correct me if I am wrong. The STORE table only has storage for one field in the PK (ITEM_ID). So it can not store the entire PK object.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033743#4033743
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033743
19 years
[JBoss Seam] - DataModelSelection returning null
by smithbstl
I am having problems with a DataModelSelection. I have an s:link in a table column and when I execute the action, the row data is not being injected into the DataModelSelection. What I am attempting to do is create nested tables where an Address list is in the parent table and matching service requests are in the child table, so there is no page navigation involved at this point.
Here is the page
<tr:table
| id="addresses_id"
| var="addressRow"
| value="#{foundAddresses}"
| rowBandingInterval="1"
| rendered="#{foundAddresses.rowCount>0}"
| rowSelection="single">
| <tr:column>
| <f:facet name="header">
| <tr:outputText value="#{msgs['AddressList.addressNumber']}"/>
| </f:facet>
| <s:link id="viewRequests" action="#{addressListing.findRequests}" value="View Requests"/>
| ....
Here is the SFSB
I am Beginning a conversation when the first datamodel(foundAddresses) is populated, then ending the conversation when the second (requests) is populated via the DataModelSelection(selectedAddress) object from the first DataModel (foundAddresses)
@Stateful
| @Name("addressListing")
| public class AddressListing implements com.stlouiscity.csb.ejb.address.AddressListingLocal {
|
| @PersistenceContext(unitName="CSB_Oracle", type=EXTENDED)
| private EntityManager em;
|
| @In(create=true)
| private Address address;
|
| @DataModel("foundAddresses")
| private List<StructureAddress> foundAddresses;
|
| @DataModelSelection(value="foundAddresses")
| private StructureAddress selectedAddress;
|
| @DataModel
| private List<ServiceRequest> requests;
|
| @Out(required=false)
| private List<String> streetDirections;
|
| /**
| * Creates a new instance of AddressListing
| */
| public AddressListing() {
| }
|
| @Begin
| public void findAddresses() {
|
| if (address.getStreetName() != null) {
| System.out.println("Address Is NOT NULL");
| //Find StructureAddress
| Query q = em.createQuery("Select a From StructureAddress a Where" +
| " (a.structureAddressPK.houseNumber = :houseNumber OR :houseNumber IS NULL) AND" +
| " (a.structureAddressPK.houseSuffix = :suffix OR :suffix IS NULL) AND" +
| " (a.nlc.streetDirection = :streetDirection OR :streetDirection IS NULL) AND" +
| " (lower(a.nlc.streetName) LIKE :street OR :street IS NULL)");
| q.setParameter("houseNumber",address.getHouseNumber());
| q.setParameter("suffix",address.getHouseSuffix());
| q.setParameter("streetDirection",address.getStreetDirection());
| q.setParameter("street",address.getStreetName().toLowerCase() + "%");
|
| foundAddresses = q.getResultList();
|
| } else if (addressLookup.getAddressLookupId() != null) {
| Query query = em.createNamedQuery("Select a from AddressLookup where a.addressLookupId = :addressLookupId");
| query.setParameter("addressLookupId", addressLookup.getAddressLookupId());
| foundAddresses = query.getResultList();
| } else {
| System.out.println("Address IS NULL");
| }
| }
| @End
| public void findRequests() {
| System.out.println("*********Made it to findRequests*********");
| if (selectedAddress != null) {
| System.out.println("Selected Address: " + selectedAddress.toString());
| //Find Request
| Query q = em.createQuery("Select p.serviceRequestCollection From ParcelAddress p Where" +
| " (p.address = :address)");
| q.setParameter("address",selectedAddress);
| requests = q.getResultList();
| } else {
| System.out.println("Selected Address IS NULL");
| }
| }
|
| @Factory("streetDirections")
| public void fillStreetDirections() {
| Query query = em.createQuery("SELECT DISTINCT n.streetDirection FROM Nlc n WHERE n.streetDirection IS NOT NULL");
| streetDirections = query.getResultList();
| }
|
| @Remove @Destroy
| public void destroy() {
|
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033738#4033738
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033738
19 years