Well, you can try a mapping framework to eliminate all the manual
setting of properties between your SupplierLookup and Supplier. The
code would look something like this when using dozer:
<code>
ArrayList<SupplierLookup> all = new ArrayList
(supplier.findAll());
ArrayList<Supplier> suppliers = new
ArrayList<Supplier>();
Mapper mapper = DozerMapperFactory.getInstance
();
for (SupplierLookup supplierLookup : all) {
suppliers.add((Supplier) mapper.map
(supplierLookup, Supplier.class));
if (suppliers.size() >= 200) break;
}
return suppliers;
</code>
http://dozer.sourceforge.net/
Hope that helps,
Salvador
On 18 mai, 10:17, Dalla <[email protected]> wrote:
> Hi all
>
> Been searching these groups and the web in general to find an answer
> to my question, but haven´t been able to wrap my head around what I´ve
> found so far.
>
> I´m playing around a bit trying to figure out how to make use of my
> existing EJBs.
>
> For example I have an existing EJB like this:
>
> package intranet.apps.supplierdatabase;
>
> import java.util.HashSet;
> import java.util.Set;
> import javax.persistence.CascadeType;
> import javax.persistence.Column;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.Id;
> import javax.persistence.NamedQuery;
> import javax.persistence.OneToMany;
> import javax.persistence.Table;
>
> /**
> * SupplierLookup entity.
> *
> * @author MyEclipse Persistence Tools
> */
>
> @NamedQuery (
> name="getNameIdPairs",
> query="select s.supplierName, s.supplierId FROM SupplierLookup
> s"
> )
>
> @Entity
> @Table(name = "SupplierLookup", schema = "dbo", catalog = "LevDB",
> uniqueConstraints = {})
> public class SupplierLookup
> implements java.io.Serializable {
>
> // Fields
> private Integer supplierId;
> private String supplierName;
> private String supplierInfo;
> private String supplierAddress;
>
> (Getters and Setters)
>
> }
>
> My interfaces like this:
>
> @RemoteServiceRelativePath("greet")
> public interface GreetingService
> extends RemoteService {
> ArrayList<Supplier> getSuppliers() throws Exception;
>
> }
>
> public interface GreetingServiceAsync {
> void getSuppliers(AsyncCallback<ArrayList<Supplier>> callback);
>
> }
>
> From what I understand, I cannot reference my EJB in the GWT client
> code, since most packages in my EJB is not part of the GWT JRE
> emulation. So currently I have created a custom POJO which is pretty
> much the same as my EJB without the EJB-part :-)
>
> My test implementation looks like this:
>
> public ArrayList<Supplier> getSuppliers() throws NamingException {
> InitialContext ctx = new InitialContext();
> SupplierLookupFacadeLocal supplier =
> (SupplierLookupFacadeLocal)
> ctx.lookup
> (SupplierLookupFacade.LOCAL_JNDI_NAME);
> ArrayList<SupplierLookup> all = new ArrayList
> (supplier.findAll());
>
> ArrayList<Supplier> suppliers = new
> ArrayList<Supplier>();
>
> for (SupplierLookup supplierLookup : all) {
> Supplier supp = new Supplier();
>
> supp.setSupplierAddress(supplierLookup.getSupplierAddress());
>
> supp.setSupplierId(supplierLookup.getSupplierId());
>
> supp.setSupplierInfo(supplierLookup.getSupplierInfo());
>
> supp.setSupplierName(supplierLookup.getSupplierName());
> suppliers.add(supp);
> if (suppliers.size() >= 200) break;
> }
>
> return suppliers;
>
> }
>
> There just HAS to be a better way to do this? There must be a way to
> send my EJB-POJO through RPC.
> I´ve tried that aswell, but then I get an exception with reference to
> the SerializationPolicy.
> Any better solutions out there?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---