While generating binding classes with JAXB I’ve recently encountered the following problem:

1
2
3
4
5
6
7
8
9
10
11
parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "net.solidsyntax.examples.jaxb.oxm.AnXSDType" is already in use. Use a class customization to resolve this conflict.
line 15 of file:/C:/xsd/CommonTypes.xsd
[ERROR] (Relevant to above error) another "AnXSDType" is generated from here.
line 10 of file:/C:/xsd/EvenMoreCommonTypes.xsd
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 15 of file:/C:/xsd/CommonTypes.xsd
[ERROR] (Related to above error) This is the other declaration.
line 10 of file:/C:/xsd/EvenMoreCommonTypes.xsd
Failed to produce code.

The problem occurred while trying to generate binding classes from an xsd (MySchema.xsd) which included CommonTypes.xsd and EvenMoreCommonTypes.xsd. Both CommonTypes.xsd and EvenMoreCommonTypes.xsd contain a type called “AnXSDType”. By default JAXB generates binding files with the same name as the type. Two source files with the same name in the same package is not possible so JAXB throws generates an exception.

How can we fix this ?

Read more »

Lately I’ve been playing around with Groovy and I tought I might try converting a Java project to Groovy. The example application which I’ve created to demonstrate Hibernate FetchMode strategies seems ideal for the task. It contains a few Hibernate entities, which are basically just Java beans. And it has a small piece of ‘application logic’. You may download the original code here. For those who can’t wait for the result the final code can be found here.

Now let’s get started ..

Read more »

Trying to optimize OneToOne mappings by setting the fetch mode to lazy does not always work as expected. I’ve created a guide about how to optimize OneToOne mappings. This guide takes a closer look at how lazy fetching is affected by the owner of a relation.

Read more »