Nargzul
asked on
Java variable arguments on constructor
I've view this:
http://today.java.net/pub/a/today/2004/04/19/varargs.html
I've try to do this on a constructor, but when I call it, I've this error:
java.lang.NoSuchMethodExce ption: datamodel.DealProposition. <init>(dat amodel.Dea l, datamodel.Deal)
I must have this because: I can give a collection/array/... as parameter(JPQL new object), and the number can have many variation(2-100)
http://today.java.net/pub/a/today/2004/04/19/varargs.html
I've try to do this on a constructor, but when I call it, I've this error:
java.lang.NoSuchMethodExce
I must have this because: I can give a collection/array/... as parameter(JPQL new object), and the number can have many variation(2-100)
What is the code you have?
ASKER
public class DealProposition {
public Deal[] dealPropList;
DealProposition(datamodel.Deal[] dllist){//I've try datamodel.Deal... dllist Too
dealPropList = dllist;
}
}
That constructor is not marked as public for one, but I will take a look if anything else.
ASKER
It does the same with public declaration.
I've the impression that is JPQL that dosn't know how to gives parameter like this.
I've the impression that is JPQL that dosn't know how to gives parameter like this.
Try like this:
public class DealProposition {
public Deal[] dealPropList;
public DealProposition(Deal ... dllist) {
dealPropList = dllist;
}
}
A simple array should have worked though, even if you are not using the variable parameter construct (...). Or possible you will need to do like this since JPQL.
public class DealProposition {
private Deal[] dealPropList;
public DealProposition() {
super();
}
public void setDealPropList(Deal[] dllist) {
this.dealPropList = dllist;
}
public Deal[] getDealPropList() {
return this.dealPropList;
}
}
ASKER
(http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/jpa_langref.html ) for one good doc on JPQL.
Here is the example request:
SELECT NEW com.company.PublisherInfo( pub.id, pub.revenue, mag.price)
FROM Publisher pub JOIN pub.magazines mag WHERE mag.price > 5.00
And they say every times it's a constructor expression, so I don't think it must have getters and setter.
Here is the example request:
SELECT NEW com.company.PublisherInfo(
FROM Publisher pub JOIN pub.magazines mag WHERE mag.price > 5.00
And they say every times it's a constructor expression, so I don't think it must have getters and setter.
ASKER
Sorry I don't have see your previous message, I just try it now and it doesn't works
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
A little dirty