2

Environment: STS (version 3.6.4 currently, but happens in prior versions as well) Hibernate 4.2.16 as JPA provider MSSQL 12.0 database

When utilizing standard Eclipse tooling (Dali) for generating JPA entities, nvarchar types map up to a type of Object (instead of the intended String). Varchar types map as desired (String).

Is this an expected behavior? If so, why would anyone WANT a column of character text to map to an Object type? I completely understand you can manually change it through the wizard (or in the code), but having it generate as intended by default would be desirable (we have hundreds of tables, if not more and is quite error prone to remember to switch these).

Any help is appreciated.

Update: To add to this, the "Data Source Explorer" also does NOT show a data type attached to this column (shows nullability, but doesn't show a data type). Appears Eclipse doesn't know what it is. Driver class being used in my data connection is: com.microsoft.sqlserver.jdbc.SQLServerDriver. Maybe driver related? Anyone ever seen this?

LetsBeFrank
  • 774
  • 11
  • 31
  • maybe Dali doesn't have full support for NVarchar so they just map unsupported types to Object? just a thought – Neil Stockton Jan 19 '16 at 14:11
  • 1
    Yes. I "think" that's what happening. That does surprise me though, as Dali is a mature product and nvarchar isn't anything new... – LetsBeFrank Jan 19 '16 at 14:31
  • See also https://stackoverflow.com/questions/5883670/why-eclipselink-maps-a-nvarchar-type-to-an-object Note that not many RDBMS support NVARCHAR so maybe Dali was developed with things like MySQL etc and never saw the need – Neil Stockton Jan 19 '16 at 15:21
  • 1
    Yeah. I saw that one. I was hoping for a better solution that modifying the generated entities if possible. Seems like an easy concept to just say "always map nvarchar to String". Aside from that, the data explorer in Eclipse seems to have the same issue (can't see datatype), so might not even be a JPA-related issue. – LetsBeFrank Jan 19 '16 at 15:35
  • Your update is on track: Dali uses the DTP driver to determine how types are mapped from the database to your generated entity. See http://stackoverflow.com/questions/13300997/why-does-eclipse-propose-object-as-default-mapping-type-for-datatype-text/13310935#13310935 – Brian Vosburgh Jan 19 '16 at 17:50
  • 1
    Any reason you can think of that the data sources explorer view cannot see nvarchar either? I tried in both Rational Application Developer and IBM Data Tools (both Eclipse-based products, but proprietary to IBM) and the nvarchar shows up fine in data sources explorer using the same connection (I exported it out of STS into RAD/etc). I think this "may" be the root of my problem... Just not sure what it'll take to fix it. – LetsBeFrank Jan 20 '16 at 04:26
  • 1
    One last note. This is ONLY on MS SQL. Oracle and DB2 have their NVARCHAR show up just fine. I tried a variety of JDBC driver versions for MS-SQL, which didn't seem to make any difference. – LetsBeFrank Jan 20 '16 at 04:27
  • All the DTP "drivers" for the various database have a variety of provenances; so they can all behave differently. One of the pain points of open source.... :-( – Brian Vosburgh Jan 20 '16 at 16:21
  • 1
    The "drivers" I was referring to weren't the DTP drivers that I was updating, but rather the drivers on the datasource connection itself to be able to connect (which are the JDBC drivers delivered by the database provider). – LetsBeFrank Jan 21 '16 at 19:03

0 Answers0