Objectless Blog

Author Archive

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...

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...

I write rhymes too

by steve on Sep.16, 2009, under Fun Stuff, Poem

my eyes went heavy as I was wiring my pojos, so I amuse myself

 

VAULT

In a cold silent shrine
Where no lights ever shine,
Dust have filled my feet
Tongue never tested bitter nor sweet.

Inside this sellar of no lust
Is a vault eaten by rust.
A receptacle of what has been
Of memories to be forgotten. 

In the shade of someone’s shadow
I lie here down below.
Six feet from someone’s feet
A barren place for rest.

As night takes the day
The spirit has left its body.
Please I beg do not disturb me
And my grave’s privacy.

Leave a Comment more...

Perversion and Programming

by steve on Sep.15, 2009, under Fun Stuff, Programming

Sex == Programming

1. Better success with Peer Collaboration
2. Inversion of Control
3. Performance is key
4. After sex/programming support is never fun
5. Best done indoors; in a dark room
6. Everyone wants it to be free and open
7. Experience is your best teacher
8. Bugs are always unwanted
9. Never forget to upgrade!
10. Men are more into it than women

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...