Hi everyone,
We actually evaluate Spring Data Graph, whether it make sense to use it for our project.
I despair at the following problem:
Sending a domain object via a Stateless Session Bean (EJB3) - remotely or locally - to a client application (also implements the domain class) does work, but there must be a problem with serialization, because the attributes of the domain object has null for each attribute on client side.
I think during serialization, the attributes can't be copied to the new object on client side, because the domain object on server side is coupled with the Interface NodeBacked? Because if I initialize another object of the domain class an fill in the attributes and then send it to the client, it works fine.
More Information with coding examples:
Domain class on server and client side: Product.java
server side: GraphServiceCode:@NodeEntity public class Product implements Serializable{ private static final long serialVersionUID = 3371733444426178897L; @Indexed long id; @Indexed(fulltext = true, indexName = "productNameIndex") String name; public Product() { } public Product(long id, String name) { this.id = id; this.name = name; } public long getId() { return id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
server side: EJBCode:@Service(value="graphService") public class GraphServiceImpl implements GraphService{ @Autowired GraphDatabaseContext ctx; @Autowired GraphRepository repository; @Autowired ProductRepository productRepository; @Transactional public Product getCopiedProduct(long id) { Product product = productRepository.findByPropertyValue("id", id); //works fine - attribute values are available when send to client via ejb Product copiedProduct = new Product(product.getId(), product.getName()); return copiedProduct; } @Transactional public Product getProduct(long id) { Product product = productRepository.findByPropertyValue("id", id); System.out.println(product.getId()); //works fine - attribute values are available System.out.println(product.getName()); //works fine - attribute values are available //but when send to client (serialized via ejb) - attributes are null return product; } }
The client test codeCode:@Stateless @Interceptors(SpringBeanAutowiringInterceptor.class) public class MyRemoteInterfaceBean implements MyRemoteInterface { @Autowired private GraphService graphService; public Product getCopiedProduct(long id) { return graphService.getCopiedProduct(id); //works fine } public Product getProduct(long id) { return graphService.getProduct(id); // null in attributes when at client } }
As you can see, the different between Product Object and copied Product Object is the connetion to interface NodeBacked during runtime. So Serialization doesn't work correctly I think.Code:MyRemoteInterface bean = (MyRemoteInterface) ctx.lookup("MyRemoteInterfaceBean/remote"); //Create product bean.createProduct(1, "MyFirstProduct"); //works fine //Load created product Product p1 = bean.getProduct(1); //No Exceptions System.out.println(p1.getName()); //but null System.out.println(p1.getId()); //but null //Load created product (copied) Product cp1 = bean.getCopiedProduct(1); System.out.println(cp1.getName()); //worls fine System.out.println(cp1.getId()); //works fine
Can you help me?


Reply With Quote
