[ https://issues.apache.org/jira/browse/OPENJPA-2534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14272686#comment-14272686 ]
Mark Struberg commented on OPENJPA-2534: ---------------------------------------- I know @Externalizer and also @ExternalValue and both are not an option. That would require us to annotate each and every boolean field. The point is that our current DBDictionary hardcoded uses (int) 0/1 and doesn't support native boolean at all. This is imo fundamentally false. Some databases which are SQL99 compatible support Boolean as own native type. For those we should imo use PreparedStatement.setBoolean() and not setInt() as we currently do! ExternalValue does not help much as Boolean always ends up as setInt atm. And for Oracle and others who don't know any native Boolean it is basically up to each installation on how they represent boolean in their db schema. I've seen the ones I mentioned above but I'm sure there are others as well. So I would probably also add BOOLEAN_BOOLEAN. This should of course be able to get changed via our normal ways: properties, specialized DBDictionary, etc. > A boolean is not converted correct when using the hint 'UseLiteralInSQL'. > ------------------------------------------------------------------------- > > Key: OPENJPA-2534 > URL: https://issues.apache.org/jira/browse/OPENJPA-2534 > Project: OpenJPA > Issue Type: Bug > Components: sql > Affects Versions: 2.1.2, 2.2.1.1, 2.2.3, 2.3.1, 2.4.0 > Reporter: Heath Thomann > Assignee: Rick Curtis > Priority: Critical > Attachments: OPENJPA-2534.patch > > > The hint, 'openjpa.hint.UseLiteralInSQL', is not properly converting a > boolean to an int. To illustrate this, lets take this entity: > public class MyEntity implements Serializable { > @Id > private Integer pk; > private boolean flag; > .......... > With this entity, lets take this test: > Query q = em.createQuery("SELECT f FROM MyEntity f WHERE f.flag = true"); > q.setHint("openjpa.hint.UseLiteralInSQL", "false"); //false is the default > q.getResultList(); > With this code, the following SQL will be generated: > SELECT t0.pk, t0.code, t0.code2, t0.flag FROM MyEntity t0 WHERE (t0.flag = ?) > [params=(int) 1] > Next, lets take this code: > Query q = em.createQuery("SELECT f FROM MyEntity f WHERE f.flag = true"); > q.setHint("openjpa.hint.UseLiteralInSQL", "true"); > q.getResultList(); > With this code, the following SQL will be generated: > SELECT t0.pk, t0.code, t0.code2, t0.flag FROM MyEntity t0 WHERE (t0.flag = > true) > However, in the latter case where UseLiteralInSQL=true, the following SQL > should be generated: > SELECT t0.pk, t0.code, t0.code2, t0.flag FROM MyEntity t0 WHERE (t0.flag = > '1') > Thanks, > Heath -- This message was sent by Atlassian JIRA (v6.3.4#6332)