zoukankan      html  css  js  c++  java
  • IllegalArgumentException: Unknown entity

    需要使用persistence.xml进行配置。

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
     3   <persistence-unit name="WebofficeOne" transaction-type="RESOURCE_LOCAL">
     4     <provider>org.hibernate.ejb.HibernatePersistence</provider>
     5 <!--     <jta-data-source>dataSource</jta-data-source> -->
     6     <class>net.etec.ftm.domain.City</class>
     7     <class>net.etec.ftm.domain.Country</class>
     8     <exclude-unlisted-classes>false</exclude-unlisted-classes>
     9     <properties>
    10         <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
    11         <property name="hibernate.show_sql" value="true"/>
    12         <property name="hibernate.hbm2ddl.auto" value="update"/>
    13         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
    14         <property name="hibernate.connection.username" value="root"/>
    15         <property name="hibernate.connection.password" value="801216"/>
    16         <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true"/>
    17         <property name="hibernate.c3p0.min_size" value="5"/>
    18         <property name="hibernate.c3p0.max_size" value="20"/>
    19         <property name="hibernate.c3p0.timeout" value="300"/>
    20         <property name="hibernate.c3p0.max_statements" value="50"/>
    21         <property name="hibernate.c3p0.idle_test_period" value="3000"/>
    22     </properties>
    23   </persistence-unit>
    24 </persistence>

    实体工厂配置

     1     <bean id="entityManagerFactory"
     2         class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
     3         <property name="persistenceUnitName" value="WebofficeOne" />
     4 <!--         <property name="dataSource" ref="dataSource" /> -->
     5         <property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
     6 <!--         <property name="packagesToScan" value="com.etec.ftm.domain" /> -->
     7         <property name="persistenceXmlLocation" value="classpath:META-INF/persistence-instance.xml"/>
     8         <property name="jpaProperties">
     9             <props>
    10                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
    11                 <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
    12                 <prop key="hibernate.show_sql">true</prop>
    13                 <prop key="hibernate.hbm2ddl.auto">create</prop>
    14             </props>
    15         </property>
    16     </bean>
  • 相关阅读:
    Delphi利用Windows GDI实现文字倾斜
    再学 GDI+文本输出文本样式
    GDI+在Delphi程序的应用 Photoshop色相饱和度明度功能
    GDI+图像与GDI位图的相互转换
    走进JavaWeb技术世界12:从手动编译打包到项目构建工具Maven
    走进JavaWeb技术世界11:单元测试框架Junit
    走进JavaWeb技术世界10:从JavaBean讲到Spring
    走进JavaWeb技术世界9:Java日志系统的诞生与发展
    走进JavaWeb技术世界8:浅析Tomcat9请求处理流程与启动部署过程
    随笔总和
  • 原文地址:https://www.cnblogs.com/javaleon/p/4024034.html
Copyright © 2011-2022 走看看