[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] How to force EclipseLink to use my own collection instead Java standards?
|
Em 30/03/2013 15:44, Edson Richter escreveu:
Hi!
I've created a collection class that implements Map<K, T>.
When I create the object for the first time, everything happens as
expected, but once I retrive the object from database (using either
find or Query), I'm getting a standard Map implementation instead my
customized version.
How can I tell EclipseLink that it must use my specialized version of
the collection class?
Current declaration is:
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "anexo", joinColumns = @JoinColumn(name =
"cadastroprofissional_id"))
@MapKeyColumn(name = "tipo")
public Map<String, Anexo> getAnexo() {
if(anexo==null) {
anexo = new AutoMap<String, Anexo>(String.class, Anexo.class);
}
return anexo;
}
Where AutoMap is my specialized Map class.
Thanks,
Edson
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
I've just found a workaround: If not my specialized collection, then I
do change the type whenever I call getAnexo() before returning.
Method became:
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "anexo", joinColumns = @JoinColumn(name =
"cadastroprofissional_id"))
@MapKeyColumn(name = "tipo")
public Map<String, Anexo> getAnexo() {
if(anexo==null || !(anexo instanceof AutoMap)) {
anexo = new AutoMap<String, Anexo>(String.class, Anexo.class, anexo);
}
return anexo;
}
These are not big bloated objects, I can deal with the encapsulation
process without any penalty.
Regards,
Edson