Friday, September 19, 2008

DBUnit and slf4j

I had never heard of slf4j before this morning, and I have no idea why.  I'm usually pretty up on stuff.

I started to pull some test data with dbunit ( in case you aren't familiar with dbunit here's an excellent intro by Bill Siggelkow ), and when I ran it I got the following error :

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.dbunit.database.AbstractDatabaseConnection.<clinit>(AbstractDatabaseConnection.java:46)
    at [my package and class].main(DBUnitExporter.java:62)

The solution is to download slf4j, and add slf4j-api-1.5.2.jar and slf4j-log4j12-1.5.2.jar to the classpath (I'm using Eclipse so I threw it in the run dialog.)
Blogged with the Flock Browser

Monday, July 21, 2008

HIbernate join tables or xref tables or cross reference tables or cross-reference tables

I just spent a bit of time figuring out how to do bidirectional one-to-many mappings that are associated with a join table / xref / cross reference / cross-reference (I'm spelling all of these out in the event that some other poor soul is searching those terms) and exist in separate schemas.

Its actually spelled out (not the separate schema part, but that's easy) on the hibernate site which shouldn't be surprising since its an excellent site.

There are two tricks to making this work :
  1. Map the children into the parent as a many-to-many, but set "unique='true'" in the mapping.
  2. Map the join table into the child object.

In my case this meant something along the lines of this in the parent :
<set name="children" table="XREF" schema="PARENT_SCHEMA"
lazy="false" inverse="true">
<key column="XREF_PARENT_ID" not-null="true" />
<many-to-many unique="true" column="XREF_CHILD_ID" class="com.jeremyrdavis.Child" />
</set>

And this in the child :
<join table="PARENT_SCHEMA.XREF" inverse="true" optional="true" >
<key column="XREF_CHILD_ID" not-null="true" />
<many-to-one name="group" column="XREF_PARENT_ID" not-null="true"></many-to-one>
</join>


Blogged with the Flock Browser

Wednesday, July 16, 2008

Terracotta at July's AJUG

Last Tuesday's AJUG (that's the Atlanta Java User's Group) presentation by Kunal Bhasin, a field engineer at Terracotta, ruled.  First of all, Kunal did a bang up job of fielding a ton of questions, and most of crowd stayed around an extra half hour for his presentation.  Second, Terracotta has a seriously cool app.  

I've attend AJUG regularly (meaning most of them) for the past few years.  Burr Sutter who runs AJUG and is the product manager for JBoss ESB does a great job with the speakers, but there have been a few that really stand out.  I got introduced to both Hibernate and Spring (although I had read about Hibernate previously) a few years back at AJUG meetings, and on both occasions got the feeling that those technologies were not only worth using but would be really big.  I got a similar impression about Terracotta; although, its nothing like either Hibernate or Spring.  Its actually pretty invisible to developers, which is the point.

In a nutshell (echoes of O'Reilly?) Terracotta's server(s) controls the objects for numerous JVMs allowing applications from each to access the same instances without any special apis.   I'm sure there's plenty of information on their site, and if you are an architect or have had to worry about clustering, caching or scaling then check it out.  They have separate sites for the commercial and open source versions (a lot like JBoss.com and JBoss.org - is this going to be the standard for oss business models now?)

Bill Sengstacken, who is in marketing, is going to post a video, and there should be a link on the AJUG site at some point.

Wednesday, June 4, 2008

Excellent post about Seam and Google bots

I haven't blogged in ages so it is pretty lame to simply link to someone else's post; however, this is an excellent piece of work. 

Its about dealing with Google bots that can crash a Seam site.
Blogged with the Flock Browser

Wednesday, April 30, 2008

'findstr' is not recognized as an internal or external command

I got this error starting JBoss from a dos prompt today :

'findstr' is not recognized as an internal or external command

I guess I had been using the ide more than usual since re-imaging my laptop.  The problem was pretty easily resolved thanks to this post on JBoss wiki.

I added C:\WINDOWS\system32 to my PATH variable and everything booted.
Blogged with the Flock Browser

Friday, April 25, 2008

Printing Arrays in Groovy

While working through the arrays page of the Getting Started Guide at the Groovy codehaus site, I stumbled upon some interesting behaviour. I was adding "print" statements to the following block of code :
assert a as List == ['a', 2, 'c', false] 
so that I ended up with :

print
"\na as List : " + a as List

The result wasn't what I expected :
["\n", "a", " ", "a", "s", " ", "L", "i", "s", "t", " ", ":", " ", "{", "\"", "a", "\"", ",", " ", "2", ",", " ", "\"", "f", "o", "o", "\"", ",", " ", "f", "a", "l", "s", "e", "}"] I added parentheses around the "a as List" and got what I expected : a as List : ["a", 2, "foo", false] Simple lesson : pay attention to precedence! That or drink coffee first thing in the morning.

Also, turning the whole string into a list that easily is cool.
Blogged with the Flock Browser

Friday, April 18, 2008

Netbeans Keyboard Shortcuts

I've been using Netbeans some recently after a the Sun Tech Days (Atlanta) and an AJUG presentation on Glassfish. Barry Hawkins' announcement at last night's (April) AJUG meeting about upcoming Python support really piqued my interest and made me decide to get comfortable using it.

My biggest annoyance when switching IDEs is not knowing the keyboard shortcuts. I despise the mouse and keep it on the left side of my desk (I'm right handed) - a Neal Ford suggestion. There is a pdf of shortcuts accessible from Netbeans' help menu, but there is a more complete list available on their wiki.
Blogged with the Flock Browser