You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Matt Magoffin <sp...@msqr.us> on 2004/08/04 19:51:00 UTC

Generate reference objects instead of primitives

Hello, is there an easy way to get XJC to generate Java objects instead
of their coresponding primitive types, eg. java.lang.Long instead of
'long' for an entire schema?

I'm trying to integrate JaxMe2 with Hibernate.

-- m@



---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: Generate reference objects instead of primitives

Posted by Matt Magoffin <sp...@msqr.us>.
It can easily use primitives, true, but for primary keys it is easiest to
use objects so that Hibernate can test if the object is persisted already
or not by the key being null. In the case of using an int for a primary
key, you end up having to tell Hibernate what the "unpersisted" value is,
which means your application must take care to always initialize the int
to some predefined value.

I could try to submit a patch with some direction, it would take me a
little bit to get set up with the JaxMe source however.

> I have not very much ideas about Hibernate, so could you please
> enlighten me: Is Hibernate actually unable to deal with non-nullable
> properties? For example, given a column like
>
>     id INT PRIMARY KEY NOT NULL
>
> then I would definitely want my Java representation to be
>
>     int id;
>
> and not
>
>     Integer id;
>
> Looking at the sources of the PrimitiveTypeSG (which is the base class
> of BooleanSG, IntegerSG, etc.), I find that your request is
> comparatively easy to fulfill: We only have to ensure, that isNullable()
>  never returns false. Question: Given some advice from our side, would
> you be ready to create a patch for providing a corresponding
> configuration parameter?
>
>
> Jochen




---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: Generate reference objects instead of primitives

Posted by Jochen Wiedmann <jo...@freenet.de>.
Matt Magoffin wrote:

>Hello, is there an easy way to get XJC to generate Java objects instead
>of their coresponding primitive types, eg. java.lang.Long instead of
>'long' for an entire schema?
>
>I'm trying to integrate JaxMe2 with Hibernate.
>  
>

I have not very much ideas about Hibernate, so could you please 
enlighten me: Is Hibernate actually unable to deal with non-nullable 
properties? For example, given a column like

    id INT PRIMARY KEY NOT NULL

then I would definitely want my Java representation to be

    int id;

and not

    Integer id;

Looking at the sources of the PrimitiveTypeSG (which is the base class 
of BooleanSG, IntegerSG, etc.), I find that your request is 
comparatively easy to fulfill: We only have to ensure, that isNullable() 
never returns false. Question: Given some advice from our side, would 
you be ready to create a patch for providing a corresponding 
configuration parameter?


Jochen


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org