Discussion:
[Middlegen-user] Changing class the determines Data type
Daniel Rosenbaum
2003-12-15 16:57:02 UTC
Permalink
Is there a way to specify a custom class that determines the data type
of a db table column? I am using middlegen with the Hibernate plugin
and the default choices do not map well for Hibernate usage. For
example, it may choose a nullible integer column to be a java int, while
it should really be an Integer since it is nullible.

Therefore it would be nice if I can implement some interface that
passes in the SQL type and I would return the datatype I would like to
use. Is there functionality for this already?

Thanks,
Daniel
Russell Simpkins
2003-12-16 11:00:00 UTC
Permalink
I don't know how to do what you ask. However, I had similar problems
running with the PostgreSql driver that shipped with Middlegen. I
upgraded to the latest jdbc driver and those problems went away.

-----Original Message-----
From: middlegen-user-***@lists.sourceforge.net
[mailto:middlegen-user-***@lists.sourceforge.net] On Behalf Of Daniel
Rosenbaum
Sent: Monday, December 15, 2003 1:56 PM
To: middlegen-***@lists.sourceforge.net
Subject: [Middlegen-user] Changing class the determines Data type

Is there a way to specify a custom class that determines the data type
of a db table column? I am using middlegen with the Hibernate plugin
and the default choices do not map well for Hibernate usage. For
example, it may choose a nullible integer column to be a java int, while
it should really be an Integer since it is nullible.

Therefore it would be nice if I can implement some interface that
passes in the SQL type and I would return the datatype I would like to
use. Is there functionality for this already?

Thanks,
Daniel


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Daniel Rosenbaum
2003-12-16 13:02:03 UTC
Permalink
I am using Oracle. I doubt that is the problem though.

Looking through the Middlegen source code, as far as I can tell, the
method that determines the Java type is the
Sql2Java.getPreferredJavaType(int sqlType, int size, int decimalDigits)
method. Notice that whether a column is nullible or not is not even
passed in and is not a determining factor in the final datatype.

I wish there was a way to override this method, and also pass in
whether the column is nullible. Perhaps by specifying the class name in
the middlegen ant task and implementing some interface, my custom method
would be called instead of Sql2Java.getPreferredJavaType(). Is there a
way already to do this? At the least, is there a way to specify that
you only want middlegen to return wrappers for primitives but not
primitives themselves?

I am thinking about implementing such functionality on my own if it is
not already available. Is this something other users would find
useful?

Thanks,
Daniel
I don't know how to do what you ask. However, I had similar problems
running with the PostgreSql driver that shipped with Middlegen. I
upgraded to the latest jdbc driver and those problems went away.

-----Original Message-----
From: middlegen-user-***@lists.sourceforge.net
[mailto:middlegen-user-***@lists.sourceforge.net] On Behalf Of
Daniel
Rosenbaum
Sent: Monday, December 15, 2003 1:56 PM
To: middlegen-***@lists.sourceforge.net
Subject: [Middlegen-user] Changing class the determines Data type

Is there a way to specify a custom class that determines the data type
of a db table column? I am using middlegen with the Hibernate plugin
and the default choices do not map well for Hibernate usage. For
example, it may choose a nullible integer column to be a java int,
while
it should really be an Integer since it is nullible.

Therefore it would be nice if I can implement some interface that
passes in the SQL type and I would return the datatype I would like to
use. Is there functionality for this already?

Thanks,
Daniel


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
middlegen-user mailing list
middlegen-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/middlegen-user


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Eivind Waaler
2003-12-18 11:57:20 UTC
Permalink
All useful changes you do will be interesting for us. Please log your
stuff in the jira if you create some good stuff:

http://jira.codehaus.org/secure/BrowseProject.jspa?id=10110

Regards
.eivind
Post by Daniel Rosenbaum
I am using Oracle. I doubt that is the problem though.
Looking through the Middlegen source code, as far as I can tell, the
method that determines the Java type is the
Sql2Java.getPreferredJavaType(int sqlType, int size, int decimalDigits)
method. Notice that whether a column is nullible or not is not even
passed in and is not a determining factor in the final datatype.
I wish there was a way to override this method, and also pass in
whether the column is nullible. Perhaps by specifying the class name in
the middlegen ant task and implementing some interface, my custom method
would be called instead of Sql2Java.getPreferredJavaType(). Is there a
way already to do this? At the least, is there a way to specify that
you only want middlegen to return wrappers for primitives but not
primitives themselves?
I am thinking about implementing such functionality on my own if it is
not already available. Is this something other users would find
useful?
Thanks,
Daniel
I don't know how to do what you ask. However, I had similar problems
running with the PostgreSql driver that shipped with Middlegen. I
upgraded to the latest jdbc driver and those problems went away.
-----Original Message-----
Daniel
Rosenbaum
Sent: Monday, December 15, 2003 1:56 PM
Subject: [Middlegen-user] Changing class the determines Data type
Is there a way to specify a custom class that determines the data type
of a db table column? I am using middlegen with the Hibernate plugin
and the default choices do not map well for Hibernate usage. For
example, it may choose a nullible integer column to be a java int,
while
it should really be an Integer since it is nullible.
Therefore it would be nice if I can implement some interface that
passes in the SQL type and I would return the datatype I would like to
use. Is there functionality for this already?
Thanks,
Daniel
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for
IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys
admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...