[EJB 3.0] - Re: Very Weird, Triplicated childs at runtime, all ok in the
by raistlinmolina
I have tired with the other parent (ParameterEJB) and form this side childs are ok, no triplicated entries.
I copy the code from ParameterEJB.java below
| @OneToMany (mappedBy = "parameter")
| public Set<ReportParameterValueEJB> getReportParameterValues(){
| return this.reportParameterValues;
| }
|
| /**
| * Sets the value of the <code>events</code> property.
| *
| * @param events the value for the <code>events</code> property
| */
| public void setReportParameterValues(Set<ReportParameterValueEJB> reportParameterValues){
| this.reportParameterValues = reportParameterValues;
| }
|
And now the corresponding side at ReportParameterValueEJB.java
| @ManyToOne (targetEntity = ParameterEJB.class, fetch = FetchType.EAGER)
| @JoinColumn (name = "idParameter", insertable=false, updatable=false)
| public ParameterEJB getParameter(){
| return this.parameter;
| }
|
| public void setParameter(ParameterEJB parameter){
| this.parameter = parameter;
| this.idParameter = parameter.getId();
| }
|
now the code at the client:
| ParameterEJB parameter = remote.getParameterByPK(1);
|
|
| if (parameter != null){
| System.out.println(parameter.getName());
| delete(parameter);
| }
| parameter = remote.getParameterByPK(2);
| if (parameter != null){
| System.out.println("Options: " + parameter.getParameterOptions().size());
| if (parameter.getParameterOptions().size() > 0){
| System.out.println("Option1: " + parameter.getParameterOptions().iterator().next().getOptionvalue());
| }
| Iterator <ReportParameterValueEJB> rpvs = parameter.getReportParameterValues().iterator();
| System.out.println("Valores asignados: " + parameter.getReportParameterValues().size());
| while ( rpvs.hasNext()){
| ReportParameterValueEJB rpv = rpvs.next();
| System.out.println("Valor asignado: " + rpv.getId()+" valor:" + rpv.getValue());
| }
|
| }
|
And the output
| Parameter created, Id:17
| Options: 0
| Values: 14
| Value PK: 3 value:27
| Value PK: 7 value:27
| Value PK: 18 value:27
| Value PK: 19 value:27
| Value PK: 11 value:27
| Value PK: 2 value:27
| Value PK: 14 value:27
| Value PK: 1 value:27
| Value PK: 17 value:27
| Value PK: 4 value:27
| Value PK: 6 value:27
| Value PK: 5 value:27
| Value PK: 15 value:34
| Value PK: 8 value:27
|
|
This relation works ok, the parameter with PK=2 has 14 childs, as the code shows.
Now, I don't understand why the other relations triplicates the childs!!!, they are the same type, they are coded equal..........
Please, If anyone sees the difference or something i'm doing wrong......
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973239#3973239
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973239
19 years, 7 months
[JBossCache] - replicating pojocache
by noamg
Hello.
I am using PojoCache from release 1.4SP1
I am trying to have a map of aspectesized objects in a pojocache between two websphere 6 application servers. After some fiddling around, the tests run well from within the server, but now I bumped into a new problem -
In my setup, ServerA starts the application on the server, sees that it is the first computer on the cache, and initializes the map, filling it with objects.
ServerB starts the application later, and gets a pointer to the map form his own PojoCache, after it was replicated to it.
ClientA connects to ServerA asks for a portion of the map (he sends a small list of keys, and recieves a small sub-map of key->value pairs), and everything works fine. The value object has a "getTotal()" method, which returns the right number as it should.
ClientB connects to ServerB, with the exact same list of keys, and it recieves the same map. When I iterate over the recieved map IN THE SERVER, and just print out the "getTotal()" result, I get the right number. When I get back to the client, and do the same, all the totals are "0".
I think I have an idea as to why this is happening - in ServerA I change the objects in memory, which causes the total field to get updated both in memory, and in the cache. After the replication to ServerB, the in-memory objects contain only "0" in their fields, but each call to a method (like "getTotal()") gets transfered to the cache, and retrieves the right number. After sending it to the client, there is no connection with the cache, and the "getTotal()" just returns the in-memory value of "0".
Am I making sense here? Is there some way to tell the cache to fill up the in-memory objects as well in some way? Or do I have to take care of it myself?
I would much appreciate any tip on the matter, and thank you very much.
Noam.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973233#3973233
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973233
19 years, 7 months