Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coalesce vs Sum generic Issue #19

Open
cnadeau opened this issue Jun 20, 2012 · 1 comment
Open

Coalesce vs Sum generic Issue #19

cnadeau opened this issue Jun 20, 2012 · 1 comment

Comments

@cnadeau
Copy link
Contributor

cnadeau commented Jun 20, 2012

here are the test cases:

Seems to be related to the fact coalesce only support values OR function, not combination of both
@test
public void testCoalesceSumFunction_BigDecimal()
{
Entity from = from(Entity.class);
Function sum = sum(from.getBigDecimalField());
// Ok if Function does not have BigDecimal generic type
Function coalesce = coalesce(sum, from.getBigDecimalField2());
Query select = select(coalesce);
assertEquals("select coalesce(sum(entity_0.bigDecimalField),entity_0.bigDecimalField2) from Entity entity_0", select.getQuery());
}

The problem seems related to the way java handles the variable parameters
@test
public void testCoalesceSumFunctions_BigDecimal()
{
Entity from = from(Entity.class);
Function sum = sum(from.getBigDecimalField());
Function sum2 = sum(from.getBigDecimalField2());
// Type safety: A generic array of Function is created for a varargs parameter
Function coalesce = coalesce(sum, sum2);
Query select = select(coalesce);
assertEquals("select coalesce(sum(entity_0.bigDecimalField),entity_0.bigDecimalField2) from Entity entity_0", select.getQuery());
}

@xjodoin
Copy link
Owner

xjodoin commented Jun 28, 2012

I can fix it using a new feature/annotation of jdk7 http://docs.oracle.com/javase/7/docs/api/java/lang/SafeVarargs.html but I have to test before what will be the impact for the java 6 user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants