Hi Lukas. On Jan 5, 11:30 am, Lukas Eder <[email protected]> wrote: > I have thought about that before - if by hierarchy of fields, you mean > having IntegerField, BooleanField, etc, classes.
Here is the Querydsl model : http://source.mysema.com/forum/mvnforum/viewthread_thread,158#703 > It's not that simple with > Java and Generics, but without multiple inheritance. Field<Integer> can be > many things including a whole table as in: > > SELECT * FROM T WHERE T.X = (SELECT *1* FROM DUAL) > > > > The *1* here defines the type for the "select field". How can I have > Select<?>.asField() return IntegerField? Does QueryDSL support that? For a single column subquery projection you get a fully typesafe expression. e.g. subquery().from(user).uniqueResult(user.age) returns a NumberExpression<Integer> > > On the other hand, I have become a bit sceptic as far as rigid type-safety > is concerned. In fact, for SQL, Java's 1, 1L and "1" may be the same. I do > not have a solution for that yet... Yes, you are right. SQL has more implicit type conversions than Java. The drawback with the rigid typesafe approach is that you will need to do some explicit conversions in some places. > > 2011/1/5 timowest <[email protected]> > > > You mention type-safety in your Wiki, but your fields have only the > > generic type and a general method signature. In jOOQ I can call > > intField.substring(0) without a compiler warning, right? > > > Defining a type hierarchy for fields might be worth it, you get more > > typesafety. > >
