将SQL表中的char列设置为休眠映射中的主键时出错

我有一个休眠映射类和SQL表,其中该表的SQL设计是:

将SQL表中的char列设置为休眠映射中的主键时出错

休眠映射类定义为,为数据类型设置char也不起作用:

palette

Java模型类:

  {
    common: { black: '#000',white: '#fff' },type: 'light',primary: {
      light: '#7986cb',main: '#3f51b5',dark: '#303f9f',contrastText: '#fff'
    },secondary: {
      light: '#ff4081',main: '#f50057',dark: '#c51162',error: {
      light: '#e57373',main: '#f44336',dark: '#d32f2f',grey: {
      '50': '#fafafa','100': '#f5f5f5','200': '#eeeeee','300': '#e0e0e0','400': '#bdbdbd','500': '#9e9e9e','600': '#757575','700': '#616161','800': '#424242','900': '#212121',A100: '#d5d5d5',A200: '#aaaaaa',A400: '#303030',A700: '#616161'
    },contrastThreshold: 3,getcontrastText: [Function: getcontrastText],augmentColor: [Function: augmentColor],tonalOffset: 0.2,text: {
      primary: 'rgba(0,0.87)',secondary: 'rgba(0,0.54)',disabled: 'rgba(0,0.38)',hint: 'rgba(0,0.38)'
    },divider: 'rgba(0,0.12)',background: { paper: '#fff',default: '#fafafa' },action: {
      active: 'rgba(0,hover: 'rgba(0,0.08)',hoverOpacity: 0.08,selected: 'rgba(0,0.14)',0.26)',disabledBackground: 'rgba(0,0.12)'
    }
  }

在SQL表中,currency_code是主键,它是char数组。如果在休眠映射和Java模型类中将其设置为字符串,则会收到错误消息,指出数据将被截断。另外,此char键不会自动递增,因此我必须从代​​码本身设置值。

请建议我如何在休眠映射类和Java代码中自动设置和处理此char主键的数据类型?

urboat19 回答:将SQL表中的char列设置为休眠映射中的主键时出错

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3160091.html

大家都在问