Page 1 of 1

@AdminPresentationCollection and ManyToMany

Posted: Mon Nov 19, 2012 7:55 am
by renob
Hey,

I would like to add ManyToMany relation between my product and a custom entity, and display it to the administration as a array.
I can't figure out how to used the @AdminPresentationCollection with a ManyToMany relation.

Could you give me a example ?

Thanks

Re: @AdminPresentationCollection and ManyToMany

Posted: Tue Nov 20, 2012 10:53 am
by renob
Resolve
I finaly find how to do it with the @AdminPresentationCollection
The solution :

MyProduct class :

Code: Select all

@ManyToMany(targetEntity = MyCustomclass.class , mappedBy="allProduct")
@AdminPresentationCollection(addType = AddMethodType.LOOKUP, friendlyName = "MyCustomclassTitle")
@BatchSize(size = 50)
protected List<MyCustomclass> myCustomclass= new ArrayList<MyCustomclass>(10);


MyCustomClass :

Code: Select all

@ManyToMany(targetEntity = MyProduct.class)
@JoinTable(name = "MYCUSTOMCLASS_PRODUCT_XREF", joinColumns = @JoinColumn(name = "MYCUSTOMCLASS_ID", referencedColumnName = "MYCUSTOMCLASS_ID"), inverseJoinColumns = @JoinColumn(name = "PRODUCT_ID", referencedColumnName = "PRODUCT_ID"))
@BatchSize(size = 50)
protected List<Product> allProduct = new ArrayList<MyProduct>();


Regard