Spring Roo
  1. Spring Roo
  2. ROO-2950

SQL Server 2008 Date Column generated as java.lang.String

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Works as Designed
    • Affects Version/s: 1.2.0.RC1
    • Fix Version/s: None
    • Component/s: PERSISTENCE
    • Labels:
      None

      Description

      when reverse engineering, any date or datetime2 column generates a java.util.String. I didn't seem to have a problem with this in the previous versions of roo. Am I missing something, or is this a problem with third-party library roo uses? Thanks!

      roo command
      -----------
      database reverse engineer --schema "adm bld" --package ~.domain --testAutomatically true

      dbre.xml
      --------
      <column name="ReleaseDate" primaryKey="false" required="true" scale="0" size="10" type="12,date"/>

      *_DbManaged.aj
      --------------
      @Column(name = "ReleaseDate", length = 10)
      @NotNull
      private java.lang.String AppVersion.releaseDate;

        Activity

        Hide
        Alan Stewart added a comment -

        Did you try the --includeNonPortableAttributes option on the reverse engineer command?

        Please use the Roo 'backup' and attach the zip here. I do not have access to any SQLServer instance, so will need to rely on the dbre.xml file

        Show
        Alan Stewart added a comment - Did you try the --includeNonPortableAttributes option on the reverse engineer command? Please use the Roo 'backup' and attach the zip here. I do not have access to any SQLServer instance, so will need to rely on the dbre.xml file
        Hide
        Alan Stewart added a comment - - edited

        I've reproduced your issue with the <column .. you listed above in another dbre project I have by inserting it into the dbre.xml file. However, unfortunately it is working as designed. The type of "12", which is java.sql.Types.VARCHAR, is being correctly transformed into a String field.

        Your date field needs to be Types.DATE (91), Types.TIME (92), or Types.TIMESTAMP (93). It appears the SQL Server JDBC driver is using Types.VARCHAR for your column.

        The only thing I can suggest is to make sure your date column is a common SQL date type in SQL Server, and not some other data type specific to this DB. For example, VARCHAR2 is an Oracle type, but not part of ANSI SQL.

        I have tested SQL Server in the past and I do recall date columns worked for me.

        Show
        Alan Stewart added a comment - - edited I've reproduced your issue with the <column .. you listed above in another dbre project I have by inserting it into the dbre.xml file. However, unfortunately it is working as designed. The type of "12", which is java.sql.Types.VARCHAR, is being correctly transformed into a String field. Your date field needs to be Types.DATE (91), Types.TIME (92), or Types.TIMESTAMP (93). It appears the SQL Server JDBC driver is using Types.VARCHAR for your column. The only thing I can suggest is to make sure your date column is a common SQL date type in SQL Server, and not some other data type specific to this DB. For example, VARCHAR2 is an Oracle type, but not part of ANSI SQL. I have tested SQL Server in the past and I do recall date columns worked for me.
        Hide
        Isaac Johnson added a comment -

        Alan, Thanks for you explanation. Great support will keep Roo going strong!

        I was able to resolve this problem by using the Microsoft SQL Server JDBC Driver 3.0, instead of the jTDS that is found for SQL Server.

        http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=21599

        It took me some time, but I was able to figure out how to use the "addon create wrapper" for the SQL Server driver. This forum post helped me out...

        http://forum.springsource.org/showthread.php?103559-Issue-with-DBRE-Oracle-JDBC

        Show
        Isaac Johnson added a comment - Alan, Thanks for you explanation. Great support will keep Roo going strong! I was able to resolve this problem by using the Microsoft SQL Server JDBC Driver 3.0, instead of the jTDS that is found for SQL Server. http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=21599 It took me some time, but I was able to figure out how to use the "addon create wrapper" for the SQL Server driver. This forum post helped me out... http://forum.springsource.org/showthread.php?103559-Issue-with-DBRE-Oracle-JDBC

          People

          • Assignee:
            Alan Stewart
            Reporter:
            Isaac Johnson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: