How can I configure a String column to use 'char' as the unit of size instead of 'byte' in DataNucleus

61 Views Asked by At

I'm using DataNucleus as my persistence layer (JDO) and am forced to use Oracle 11g as a database (using 11g XE for development). Unfortunately since version 11.2 the default length semantics (NLS_LENGTH_SEMANTICS) for VARCHAR columns have been set to byte instead of char which means that all columns that only provide a size will result in a type definition like this:

VARCHAR2(50 byte)

instead of:

VARCHAR2(50 char)

From Oracle's perspective the solution is threefold:

  1. declare a unit in your size definiton (what I'm trying to achieve with JDO metadata)
  2. alter the NLS_LENGTH_SEMANTICS attribute on every session
  3. alter the NLS_LENGTH_SEMANTICS attribute globally (which seems not to work with the "Express Edition", I've already wasted a whole day on this)

I've searched the Mapping and Persistence Documention up and down to find metadata attributes that let me do this. I can specify jdbcType, sqlType and of course length for a column. But no unit.

Any help would be greatly appreciated.

0

There are 0 best solutions below