This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 126438

Summary: Unsigned field not generated correctly in Entity Beans
Product: javaee Reporter: calvin_x_cheng <calvin_x_cheng>
Component: PersistenceAssignee: Andrei Badea <abadea>
Status: NEW ---    
Severity: blocker CC: pjiricka
Priority: P2    
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:

Description calvin_x_cheng 2008-01-31 19:20:13 UTC
I generated a new Entity class from a MySQL database table. According to MySQL JDBC spec, the unsigned field is returned
as a Long. But the Entity class generated by NetBeans 6.0 creates an Integer, instead of Long. This causes run time
exceptions when a value larger than 2^31 is returned.

The behavior is the same for 5.5.
Comment 1 Kirill Sorokin 2008-01-31 21:19:29 UTC
I believe this belongs to j2ee support.
Comment 2 Petr Jiricka 2008-03-26 15:35:57 UTC
Just to be clear, is this about the "EJB entity beans" in an J2EE 1.4 EJB module? Or does this relate to the "Java
Persistence", which is a part of Java EE 5?
Comment 3 calvin_x_cheng 2008-03-26 15:59:52 UTC
I was generating classes for Java EE5.
Comment 4 Petr Jiricka 2008-03-26 17:52:38 UTC
Ok, in this case this belongs to Java Persistence, changing the category accordingly.
Comment 5 Andrei Badea 2008-03-27 12:30:02 UTC
I don't know a database-independent way to detect an unsigned column. Both INT and INT UNSIGNED are mapped to
java.sql.Types.INTEGER, and both have a column size of 10. The only way I can think of is to look at the TYPE_NAME
column of java.sql.DatabasMetaData.getColumns(), but that would make the generation process database-dependent. It
currently isn't, and there is no clean, practical way to make it so for 6.1. I would prefer avoiding a hack like if
(isMySQL() && typeName.contains("UNSIGNED")).