I guess the suffix solution is not harmful and we can always expose the more elaborate solution if needed later.
On 11 janv. 2010, at 17:23, Steve Ebersole wrote: > I need to add a way to further define the type of numeric literals. > Currently HQL supports the use of the 'F', 'D' and 'L' suffixes as > defined by Java to demarcate floats, doubles and longs respectively. I > find myself the need to do the same with BigInteger and BigDecimal. > > I see two options: > > 1) 2 new suffixes ( 'BI' and 'BD'? ) > 2) new escape syntax ( {as BigInteger 10000000} ? ) > > As a side note, I could in fact just use the CAST function as HQL does > support notion like CAST( 10000000 AS java.math.BigDecimal ). However > that results in a SQL cast as well, and we get into potential issues > with "bad dialect setup". Ideally I am just looking for a way to > identify the exact java type to use. > > As an example of why this is important... The issue I ran into deals > with the JPA rules for determining query return types. Take a > multiplication: JPA says that a multiplication that involves a > BigInteger as one of its operands should return a BigInteger. So > consider "select some.attributePath * 10000000 ...". If > 'some.attributePath' is defined as Integer, this multiplication will > result in a Integer value because the '10000000' literal will also be > interpreted as Integer. > > This can also be useful for parameters as well (although this whole > issue is generally related to select clauses and many databases have > well defined restrictions on using parameters in select, at least > without the explicit CAST so they know what types to expect). > > So as far as an escape syntax, I guess the main question is how > generally useful this might be in other clauses and across other data > types. > > Anyone else run across similar needs that would impact here? > > -- > Steve Ebersole <st...@hibernate.org> > Hibernate.org > > _______________________________________________ > hibernate-dev mailing list > hibernate-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/hibernate-dev _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev