小编Ale*_*lex的帖子

在Hibernate和PostgreSQL中使用UserType的数组 - > MappingException

我正在尝试编写一个实现UserType的类来处理Hibernate/JPA中的数组.我使用以下帖子 使用hibernateHibernate/JPA/HSQL 映射postgres数组:如何为用户类型ARRAY创建Dialect映射以构建解决方案,但我无法使其工作.我创建了一个新的Spring Roo项目来测试它.以下是不同的文件(所有java类都位于包测试中):

  • persistence.xml中

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
        <!--  <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> -->
        <property name="hibernate.dialect" value="test.PostgreSQLDialectArray"/>
        <!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
        <property name="hibernate.hbm2ddl.auto" value="create"/>
        <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
        <property name="hibernate.connection.charSet" value="UTF-8"/>
        <!-- Uncomment …
    Run Code Online (Sandbox Code Playgroud)

java arrays postgresql spring hibernate

15
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×1

hibernate ×1

java ×1

postgresql ×1

spring ×1