Objectless Blog

Grails boolean saved as BIT

by steve on Dec.30, 2009, under Programming

Depending on the Grails version booleans  are stored differently; either as INT or BIT.   BIT(1) is a special datatype made just for booleans.  However old dogs prefer storing booleans as small int.  In order to do this, you have to create a customized Hibernate dialect.
MySQL Example:  foo.bar.brewsoftcorp.CustomMySQL5InnoDBDialect.groovy
package foo.bar.brewsoftcorp
import org.hibernate.dialect.MySQL5InnoDBDialect
import java.sql.Types
class CustomMySQL5InnoDBDialect extends MySQL5InnoDBDialect {
CustomMySQL5InnoDBDialect() {
registerColumnType(Types.BIT, ‘boolean’)
}
}
package foo.bar.brewsoftcorp
import org.hibernate.dialect.MySQL5InnoDBDialect
import java.sql.Types
class CustomMySQL5InnoDBDialect extends MySQL5InnoDBDialect {
CustomMySQL5InnoDBDialect () {
registerColumnType(Types.BIT, ‘boolean’)
}
}
SQL2000/2005 Example: foo.bar.brewsoftcorp.CustomSQLServerDBDialect.groovy
package foo.bar.brewsoftcorp
import org.hibernate.dialect.SQLServerDialect
import java.sql.Types
public class CustomSQLServerDBDialect extends SQLServerDialect {
public CustomSQLServerDBDialect() {
registerColumnType(Types.BIT, ‘boolean’)
}
}
Then add this line to your DataSource.groovy
dialect = util.CustomMySQL5InnoDBDialect //for MySQL
##############################
dataSource {
pooled = true
driverClassName = “com.mysql.jdbc.Driver”
username = “username”
password = “password”
dialect = util.CustomMySQL5InnoDBDialect
}
##############################

Depending on the Grails version booleans  are stored differently; either as INT or BIT.   BIT(1) is a special datatype made just for booleans.  However old dogs prefer storing booleans as small int.  In order to do this, you have to create a customized Hibernate dialect.

MySQL Example:  foo.bar.brewsoftcorp.CustomMySQL5InnoDBDialect.groovy

package foo.bar.brewsoftcorp
import org.hibernate.dialect.MySQL5InnoDBDialect
import java.sql.Types
class CustomMySQL5InnoDBDialect extends MySQL5InnoDBDialect {

CustomMySQL5InnoDBDialect() {
registerColumnType(Types.BIT, ‘boolean’)
}
}

SQL2000/2005 Example: foo.bar.brewsoftcorp.CustomSQLServerDBDialect.groovy

package foo.bar.brewsoftcorp
import org.hibernate.dialect.SQLServerDialect
import java.sql.Types

public class CustomSQLServerDBDialect extends SQLServerDialect {
public CustomSQLServerDBDialect() {
registerColumnType(Types.BIT, ‘boolean’)
}
}

Then add this line to your DataSource.groovy
dialect = util.CustomMySQL5InnoDBDialect //for MySQL

##############################

dataSource {
pooled = true
driverClassName = “com.mysql.jdbc.Driver”
username = “username”
password = “password”
dialect = util.CustomMySQL5InnoDBDialect
}

##############################

Leave a Comment more...

Torrefranca Family Picture 2009

by Lillian on Dec.28, 2009, under Family, Photo

Torrefranca Family Photo 2009

Torrefranca Family Photo 2009

Torrefranca Family Photo 2009

Torrefranca Family Photo 2009

Torrefranca Family Photo 2009

Torrefranca Family Photo 2009

Leave a Comment : more...

Grails 1.2-M3 to 1.2-M4 Upgrade Quirks

by admin on Nov.17, 2009, under Programming

Yes quirk would be the right word.

For the past weeks I have been building an ERP system from scratch using Grails 1.2-M3 using  the following plugins;

  1. Grails Security
  2. GrailsUI
  3. ImageToolkit
  4. Jasper

So when I heard about Grails 1.2’s 4th milestone, I eagerly downloaded it, made the usual changes to my dev PC’s configuration as well as in eclipse and ran grails upgrade via command line.  As expected everything works except that my datatable does not work anymore and I could not run grails from eclipse.

After a few hours of digging through the error messages and new M4 configuration, I was able to solve my problem.  Here is what I did;

  1. The grails upgrade command does not modify your project’s ivy.xml.  Simple change rev=”1.2-M3” to rev=”1.2-M4”
  2. It seems that tomcat does not know where to place the javascript folders  in the right place, causing grails-ui to misbehave.  Go to <HOME>\.grails\1.2-M4\plugins and extract the grails-grails-ui-1.1.1.zip\webapp\js\grailsui folder to your <GRAILS_PROJECT>\webapp\plugins\
  3. Delete your old project directory <HOME>\.grails\1.2-M4\projects\<PROJECT_NAME>
  4. Delete all jars under <GRAILS_PROJECT>\lib\build
  5. Run Clean
Leave a Comment :, , , more...

I wish that I could freeze the picture

by steve on Oct.06, 2009, under Family

RSCN0766

Slipping through my fingers all the time

Schoolbag in hand, she leaves home in the early morning
Waving goodbye with an absent-minded smile
I watch her go with a surge of that well-known sadness
And I have to sit down for a while
The feeling that I’m losing her forever
And without really entering her world
I’m glad whenever I can share her laughter
That funny little girl

Slipping through my fingers all the time
I try to capture every minute
The feeling in it
Slipping through my fingers all the time
Do I really see what’s in her mind
Each time I think I’m close to knowing
She keeps on growing
Slipping through my fingers all the time

Sleep in our eyes, her and me at the breakfast table
Barely awake, I let precious time go by
Then when she’s gone there’s that odd melancholy feeling
And a sense of guilt I can’t deny
What happened to the wonderful adventures
The places I had planned for us to go
Well, some of that we did but most we didn’t
And why I just don’t know

Slipping through my fingers all the time
I try to capture every minute
The feeling in it
Slipping through my fingers all the time
Do I really see what’s in her mind
Each time I think I’m close to knowing
She keeps on growing
Slipping through my fingers all the time

Sometimes I wish that I could freeze the picture
And save it from the funny tricks of time
Slipping through my fingers
Slipping through my fingers all the time
Schoolbag in hand she leaves home in the early morning
Waving goodbye with an absent-minded smile

Leave a Comment more...

To AMF or not to AMF that is the JSON

by steve on Oct.06, 2009, under Programming

Ok I admit the title is corny.

All of the Flex applications that we have written in the past years have been using XML. I mean why not? It is simpler to use, easier to understand and teach to new developers, easy integration with our existing Grails apps via REST/webservice, and most importantly it’s open! What actually scares me is the nature of AMF being a native serialized object built and written for the Flash Player.

But why must this guy post his performance test between XML and AMF (http://www.jamesward.com/census/) and pulls me out of dreamland? Now I am having second thoughts of moving to AMF. Though I am not sure if there are even stable opensource java-amf projects (stable being > 1.x release). The building directory kiosks that we have right now are wirelessly connected to the data server which shares the same bandwidth with the streaming video from the ads server. Performance is a priority in the kiosk as users expect it to perform like a desktop application. Using XML does not only waste a lot of bandwidth, much work is shoved thru the machine to parse the XML file. That was the reason why much study was made whether or not Atom processors were good enough for the kiosks.

There are actually two ways to cross the dark side; out of the XML light. One would be Grails-BlazeDS via Flex plugin. The plugin pretty much does the configuration for you. Just don’t expect flex views! Another way would be to use JSON which has been hanging around with Grails core since < 1.x. This could be a better alternative as JSON is supported by most web programming languages.  Though AMF performs better than JSON, as most tests suggest, but the difference is negligible.  I guess the deciding factor here is maintenance and which language is easier for developers.  I believe it is safe to say that more developers are familiar with JSON than AMF.  Hiring devs with Flex-AMF-Java experience might be more difficult for our clients for post production support.

1 Comment more...

Upgrades are not always good… even for Grails

by steve on Oct.06, 2009, under Programming

I have had numerous Grails projects all written using 1.0. I have been itching to upgrade to 1.1. But as I do a project upgrade, a few of my plugins refuse to work with the new distribution.

Finally two new Grails projects! So I cleaned up my old desktop and downloaded the latest Grails release (Grails 1.1.1). I spent 3 hours digging through the new Grails website for plugins that I can use. I listed down a few promising ones (stark, export, grails UI, tomcat, etc)

So I gave it a test run! I made a sort of online reservation form with export to excel and pdf capability. Out of Grails 1.0 habit I did an upgrade command and to my surprised it failed! Nice! Some hibernate plugins can’t be deleted. Grails clean seems to work perfectly though.

Since my second and third try also failed, I manually deleted the project plugins @ .grails folder. The upgrade command worked this time. But I have to manually delete the plugins for the command to work. Ok no beggie!

So I spent a day testing some plugins. I love the Stark and Jasper plugins. Though you have to use IReport 2.x as the new IReport version does not work with the current jasper plugin. It seems that the jasper engine that grails uses only supports DTD. I did several workaround like adding the old doctype that the engine expects. So to avoid the same hair pulling misery that I had encountered stick with the old, ugly, dtd based IReport designer. Anyway as my journey continues, my small app was working nicely on my dev environment.

After downloading tomcat xampp add-on, we use xampp because we are lazy, I was ready to build my first Grails 1.1.1 war. I did a grails clean command this time via eclipse (ant task target:clean) which finished without a glitch. I wish I could say the same thing with war. Running the ant task gives me a java.lang.reflect.InvocationTargetException build error which usually occurs when the compiler sees 2 different classes with the same name. So again I deleted the plugins at .grails folder ran grails war this time via commandline and it worked! So again I tried running the ant task via IDE same error! Now call me crazy I did this several times and it gives me the same result.

No happy ending with this one. I am not sure if these are known issues and developers are doing workarounds. I have never experience these issues with the old Grails. Maven issues or perhaps plugin developers putting grails jar in their distributions? I don’t know… I am just a programmer.

Leave a Comment more...

Just a Thought

by Lillian on Sep.26, 2009, under Fun Stuff

Once in a while

You’ll see a flower bloom

You’ll see an egg hatch

You’ll see the river rise,

This means a new beginning.

Once in your life

Your heart will suddenly stumble

Your mind will trust,

Your emotion will go wild,

This means you’re in love.

Once in your life

Your heart will suddenly stop beating

Your emotion and mind will go mad and crazy,

Your eye will tear

This means you’re hurt.

A new life? A new beginning?

Someone to know? Someone to share with?

Somebody to care? Somebody to love?

Someone to hate? Someone to hurt?

This means you’re near the end…

Another life… another start…

A new beginning…..

07/24/90

nohM/Llian

Leave a Comment :, more...

Lillian

by Lillian on Sep.26, 2009, under Fun Stuff

Lillian

Lillian

is

luxury

likable

innocent

and

naf.


Lillian

Love

is

like

lovebirds

in

a

nest.


Llian

Lovely

like

i

and

naughty.


by: Mhon 06/26/90




Leave a Comment :, more...



Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...