Boolean value not updated in CRUD

273 views
Skip to first unread message

indrek

unread,
Mar 14, 2011, 5:08:29 PM3/14/11
to play-framework
Can't find a way to update boolean value in CRUD. I can edit it
directly in the database, but changes made in CRUD to the boolean
value aren't saved (all other values are updated). Using MySQL 5.5 and
MySQL5InnoDBDialect

Ideas?

Werner Vesterås

unread,
Mar 14, 2011, 6:09:24 PM3/14/11
to play-framework
What version of Play are you running?

You should try to set jpa.debugSQL to true in your application.conf,
and then monitor the SQL queries issued against the database when you
edit a record.

Werner
Oslo, Norway

indrek

unread,
Mar 15, 2011, 12:41:04 PM3/15/11
to play-framework
Oops, accidentally replied to the author.

Running play 1.1.1

The jpa.debugSQL doesn't help, as it shows the update SQL which also
incldues the boolean field, but it doesn't show the parameter
bindings. Unfortunately I couldn't figure out how to make Hibernate
logging to display parameter bindings.

Indrek

Werner Vesterås

unread,
Mar 15, 2011, 2:04:58 PM3/15/11
to play-framework
According to the Hibernate documentation, you should be able to log
the value of the bindings by setting the log level for
org.hibernate.type to TRACE.

I've tried it myself, but to no avail. Maybe it is because of this
old bug, which is not resolved yet: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2835

But maybe you have better luck than me. Create a log4j.xml file under
conf, like this:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
threshold="all">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="encoding" value="ISO-8859-1"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss}
%5p ~ %m%n" />
</layout>
</appender>

<appender name="file" class="org.apache.log4j.FileAppender">
<param name="File" value="play.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value=" %-4r [%t] %-5p %c %x - %m
%n" />
</layout>
</appender>

<logger name="org.hibernate.SQL">
<level value="DEBUG" />
</logger>

<logger name="org.hibernate.type">
<level value="TRACE" />
</logger>

<root>
<level value="DEBUG" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>
</log4j:configuration>

---
Werner
Oslo, Norway

indrek

unread,
Mar 15, 2011, 3:31:00 PM3/15/11
to play-framework
Worked for me, shows parameters nicely.
From the SQL side:
The boolean value that was loaded from the database is submitted,
disregarding the checkbox value.


I also looked at the HTML source:
<input id="object_isVisible" class="" type="checkbox"
name="object.isVisible" value="true" size="50" />
<input type="hidden" name="object.isVisible" value="false" />

Seems a bit alarming, that the names of different input fields are
same and they aren't array's (object.isVisible[]). Maybe this is
allowed, I'm no HTML/HTTP headers guru. Currently, if I have checkbox
checked, the POST data looks the following:
-----------------------------18756118404966
Content-Disposition: form-data; name="object.isVisible"

true
-----------------------------18756118404966
Content-Disposition: form-data; name="object.isVisible"

false


For some reason I believe that only the last value is always read and
the input fields aren't meant to be like that. Maybe the hidden field
name should've been name="_object.isVisible". Hope you got my point
and can comment on it.

Indrek

Werner Vesterås

unread,
Mar 15, 2011, 4:23:14 PM3/15/11
to play-framework
This Stackoverflow article explains your issue better than I can do:
http://stackoverflow.com/questions/4597996/why-does-a-checkbox-also-have-a-hidden-tag-with-it

---
Werner
Oslo, Norway

indrek

unread,
Mar 16, 2011, 4:12:14 PM3/16/11
to play-framework
Ok, so that should be correct. But should I file a bug report about
this CRUD bug or any ideas?
If I only change the checkbox value and don't change any other fields,
then no SQL update query is called.

Indrek

On Mar 15, 10:23 pm, Werner Vesterås <wvester...@gmail.com> wrote:
> This Stackoverflow article explains your issue better than I can do:http://stackoverflow.com/questions/4597996/why-does-a-checkbox-also-h...
>
> ---
> Werner
> Oslo, Norway
Reply all
Reply to author
Forward
0 new messages