Boolean mapping

436 views
Skip to first unread message

posztos

unread,
Aug 28, 2009, 1:20:39 PM8/28/09
to Ebean ORM
Hi,
I still have problems with boolean to varchar mapping using postgres,
with trunk version (building trunk from source isn't obvious either -
there is a failing test).

javax.persistence.PersistenceException:
org.postgresql.util.PSQLException: ERROR: column "valid" is of type
character but expression is of type boolean
Hint: You will need to rewrite or cast the expression.
Position: 43
at com.avaje.ebean.server.persist.dml.DmlBeanPersister.execute
(DmlBeanPersister.java:107)
at com.avaje.ebean.server.persist.dml.DmlBeanPersister.insert
(DmlBeanPersister.java:74)
at
com.avaje.ebean.server.persist.DefaultPersistExecute.executeInsertBean
(DefaultPersistExecute.java:94)
at com.avaje.ebean.server.core.PersistRequestBean.executeNow
(PersistRequestBean.java:357)
at
com.avaje.ebean.server.core.PersistRequestBean.executeOrQueue
(PersistRequestBean.java:387)
at com.avaje.ebean.server.persist.DefaultPersister.insert
(DefaultPersister.java:260)
at com.avaje.ebean.server.persist.DefaultPersister.saveVanilla
(DefaultPersister.java:235)
at com.avaje.ebean.server.persist.DefaultPersister.save
(DefaultPersister.java:211)
at com.avaje.ebean.server.persist.DefaultPersister.saveRecurse
(DefaultPersister.java:176)
at com.avaje.ebean.server.persist.DefaultPersister.save
(DefaultPersister.java:161)
at com.avaje.ebean.server.core.DefaultServer.save
(DefaultServer.java:1147)
at com.avaje.ebean.server.core.DefaultServer.save
(DefaultServer.java:1137)
at com.avaje.ebean.Ebean.save(Ebean.java:520)
....

Thanks,
Greg

Rob Bygrave

unread,
Aug 28, 2009, 7:29:00 PM8/28/09
to eb...@googlegroups.com

There is a MainDbBoolean class in core:   com.avaje.tests.basic

Its run as a static void main() ... rather than JUnit  (you need to manually adjust the DB connection for Postgres/Oracle).

It uses String T/F and passes the asserts I have in there.  Can you have a look at that and see if you can get that to run/pass. Assuming it passes can you see if there is anything different to what you are doing (its using programmatic configuration).

NB: It will create a table called t_oneb ...

>> building trunk from source isn't obvious either - there is a failing test

Ok, any pointers and I'll update the 'how to build' document on the google group.
 

Thanks, Rob.

posztos

unread,
Aug 30, 2009, 12:03:17 PM8/30/09
to Ebean ORM
I tried with ddl, which generated varchar(2) columns for enum mappings
(though I have only one char sized constants), and boolean columns for
booleans.
I'm using a customized version of the "exampleOrder" ebean.properties,
and no configuration in code.
In the description of bug 138, you wrote, that using
ebean.type.boolean.false=0 / true=1 is deprecated, but it is used in
example properties file. Using the example config file, which is the
ebeanServer (for the properties databaseBooleanTrue/False) ?


There are 2 tests failing with trunk (r461):

-------------------------------------------------------------------------------
Test set: com.avaje.tests.basic.TestSerialization
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.036
sec <<< FAILURE!
testSerialization(com.avaje.tests.basic.TestSerialization) Time
elapsed: 0.029 sec <<< FAILURE!
junit.framework.AssertionFailedError: should be an EntityBean
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertFalse(Assert.java:34)
at com.avaje.tests.basic.TestSerialization.testSerialization
(TestSerialization.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run
(JUnit38ClassRunner.java:81)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute
(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet
(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute
(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess
(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main
(SurefireBooter.java:997)


-------------------------------------------------------------------------------
Test set: com.avaje.tests.query.TestLimitQuery
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.005
sec <<< FAILURE!
testHasManyWithLimit(com.avaje.tests.query.TestLimitQuery) Time
elapsed: 0.003 sec <<< ERROR!
java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:
157)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:
730)
at com.avaje.ebean.server.deploy.BeanDescriptor.getElPropertyDeploy
(BeanDescriptor.java:1256)
at com.avaje.ebean.util.DefaultExpressionList.containsMany
(DefaultExpressionList.java:75)
at com.avaje.ebean.server.querydefn.DefaultOrmQuery.isManyInWhere
(DefaultOrmQuery.java:232)
at com.avaje.ebean.server.core.DefaultServer.createQueryRequest
(DefaultServer.java:1050)
at com.avaje.ebean.server.core.DefaultServer.findList
(DefaultServer.java:1291)
at com.avaje.ebean.server.querydefn.DefaultOrmQuery.findList
(DefaultOrmQuery.java:621)
at com.avaje.tests.query.TestLimitQuery.testHasManyWithLimit
(TestLimitQuery.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run
(JUnit38ClassRunner.java:81)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute
(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet
(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute
(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess
(SurefireBooter.java:338)
at org.apache.maven.surefire.booter.SurefireBooter.main
(SurefireBooter.java:997)


Thanks,
Greg

Rob Bygrave

unread,
Aug 30, 2009, 6:29:06 PM8/30/09
to eb...@googlegroups.com
The tests where fixed last night (r464 now) so they will pass with the latest code.



>> I tried with ddl, which generated varchar(2) columns

Ok, I was hoping you would run the MainDbBoolean and make sure that it is working for you. I may be getting confused as to what problem you have now.

>> and boolean columns for booleans.

Was the problem mapping to DB varchar columns or  DB boolean columns? Are you using your own DDL? I'm confused now...

>> ... ebean.type.boolean.false=0 / true=1 is deprecated, but it is used in
example properties file

That is a bug in the example properties file - sorry!! The ServerConfig.loadProperties() method will not load those values (apologies... I decided to make it consistent with the ServerConfig property names which I think makes sense)

Maybe a good approach would be to create a small program like MainDbBoolean that shows the problem(s) you have got at the moment. I don't quite follow how you are using/generating DB boolean columns?


Thanks, Rob.

posztos

unread,
Aug 31, 2009, 10:09:51 AM8/31/09
to Ebean ORM
With r464 all tests pass, including MainDbBoolean.

My problem is caused by my ebean.properties file... I'd like to avoid
configuration in code, so could you update the example config file (to
include the working versions of ebean.type.boolean.false/true
properties)?

Thanks,
Greg


On aug. 31, 00:29, Rob Bygrave <robin.bygr...@gmail.com> wrote:
> The tests where fixed last night
> (*r464<http://ebeanorm.svn.sourceforge.net/viewvc/ebeanorm?view=rev&revision...>
> * now) so they will pass with the latest code.
>
> *>> I tried with ddl, which generated varchar(2) columns*
>
> Ok, I was hoping you would run the MainDbBoolean and make sure that it is
> working for you. I may be getting confused as to what problem you have now.
>
> *>> and boolean columns for booleans.
> *
> Was the problem mapping to DB varchar columns or  DB boolean columns? Are
> you using your own DDL? I'm confused now...
>
> *>> ... ebean.type.boolean.false=0 / true=1 is deprecated, but it is used in
> example properties file
> *
> ...
>
> tovább »

Rob Bygrave

unread,
Aug 31, 2009, 6:08:29 PM8/31/09
to eb...@googlegroups.com

>> so could you update the example config file

Yes, I'll do that. Thanks for pointing it out.

Where "myserver" is the name for the EbeanServer ... have in the ebean.properties use something like:

ebean.myserver.databaseBooleanTrue=T
ebean.myserver.databaseBooleanTrue=F


Ebean will check to see if your true/false values are integers or strings. In the case above "T" and "F" are not integers so Ebean will map booleans to DB  VARCHAR with values "T" and "F".  If they where "0", "1" Ebean would map booleans to DB INTEGER type with 0 and 1 values.


Cheers, Rob.
Reply all
Reply to author
Forward
0 new messages