JBoss with SQL Server and EJB3 is giving me a hard time

Today I had a bit of a fuss with JBoss and SQL Server. For some reason, when I declare an entity with an Id field, the persistency layer tries to push a bad query to the database.

Let me explain.

I’ve got an entity sort of looking like this:

@Entity
public class Contract {

@Id
@GeneratedValue(strategy = GenerationType.Identity)
private int contractId;
...
}

When tryin to persist this through the entity manager SQL trace on MS SQL show a query somewhat looking like:

insert into Contract (contractid, ...) values (null, ...)

You see, a null value. Sounds reasonable, I didn’t set any value on the contractid field. BUT the persistency layer should not try to insert anything into the contractid column, because MSSQL doesn’t allow it. The above SQL results in a “DEFAULT or NULL are not allowed as explicit identity values.” I’m not sure what to try next though, everywhere I looked on the internet, all examples boil down too: “Something similar should work in MS SQL too, but I haven’t tested that…”

Better luck tomorrow. For now, I googled my brains out trying to find anything helpfull.

Anybody out there have any suggestions?

Update on the next day:
It turns out that the problem was the dialect configured in the Hibernate properties in the persistence.xml. By default our development environment enters the right value for Hypersonic DB, while it should actually be like this:

<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>

And now it all works. A default SQL Server 2005 with JBoss and the latest MSSQL JDBC driver, all running EJB3.

Upgraded WordPress to 2.8

I’ve updated WordPress to 2.8 last night. I haven’t seen any problems myself so far. But if you do notice something, please let me know.

Which reminds me, does the mail form still work after this update… I’ll go check that right now. 🙂

.
.
.
It still works. 🙂

Back from the JavaOne 2009

Phew, back from the JavaOne 2009 again.

Too bad Jonathan's assistent didn't allow my camera to focus. First time I’ve been there. And boy could you feel the recession at the JavaOne… I think the number of visitors was at an all time low. Also in San Francisco itself recession was around you. Loads and loads of properties available for lease or sale.

But me and my colleagues did our best to support the global and local economy by living large. 🙂 Besides the conference we did all sorts of fun activities. I even biked the Golden Gate the last Friday afternoon.

I also learned a valuable lesson when returning from another time-zone. When I got home I did some things and then went to my girl’s place. I should’ve asked her to keep me awake at all costs. Sunday I sat down on her couch and I kind of instantly fell asleep. I paid the price on Monday and Tuesday. Fortunately my employer was very understanding about Monday and Tuesday I’ll recover by working a few extra hours this week or next week. 🙂

More to come later. Suffice to say that on record nobody from Sun was allowed to spill any details on the Oracle/Sun merger. I understood of the record that there will be another JavaOne next year. Let’s hope that by then it is clear what will happen with Java, cause right now it’s anybodies guess what Oracle has in store for us. I’m expecting a whole lot, but it is still a bit early to say what exactly Oracle will keep and what Oracle will throw away. I do think JavaFX is here to stay though, the new JavaFX 1.2 is a major improvement compared to the 1.1 release. Check Paul Bakker’s entry on JavaFX for more details.

Too bad the assistant of Jonathan Swartz didn’t allow my camera to focus properly.

Also many thanks to Bert, Paul, Marcel and Hans for being such great travel companions throughout the week.