Hibernate使用过程遇到的坑
来源:互联网 发布:模拟登陆知乎 编辑:程序博客网 时间:2024/06/10 03:52
版本5.1.0
使用Hibernate+JPA 注解
persistence.xml如下
注意:属性的name都是以hibernate开头
<?xml version="1.0" encoding="UTF-8"?><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 persistence_1_0.xsd"> <persistence-unit name="entityManager"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.archive.autodetection" value="class, hbm" /> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:33067/hibernate" /> <property name="hibernate.connection.username" value="root" /> <property name="hibernate.connection.password" value="root" /> <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" /> <property name="hibernate.c3p0.max_size" value="80" /> <property name="hibernate.c3p0.min_size" value="5" /> <property name="hibernate.c3p0.timeout" value="12000" /> <property name="hibernate.c3p0.max_statements" value="1000" /> <property name="hibernate.c3p0.idle_test_period" value="30000" /> <property name="show_sql" value="true" /> <property name="hibernate.hbm2ddl.auto" value="update" /> </properties> </persistence-unit></persistence>
在使用注解的过程遇到的问题,name代表的名称
问题1、
@Entity@Table(name = "msg")
这种注解会报错 javax.persistence.Table.indexes()[Ljavax/persistence/Index;
可以这样写
@Entity(name = "msg")
问题2:
在使用@ManyToOne(cascade = CascadeType.ALL)注解是不能使用@JoinColumn(name = “next_id”),否则会报javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey;异常。不加joincolnum自动生成外键id名称即可。
0 0
- Hibernate使用过程遇到的坑
- 使用Hibernate遇到的坑
- 使用Hibernate过程中所遇到的问题已经解决方法
- Glide使用过程中遇到的坑
- 使用jquery过程中遇到的坑
- 使用Realm过程中遇到的坑
- Thymeleaf使用过程中遇到的坑
- RabbitMQ使用过程中遇到的坑
- 使用AlertDialog过程中遇到的坑
- RxJava2使用过程中遇到的坑
- appium使用过程中遇到的坑
- 使用JTable过程中遇到的两个坑
- Android Studio 使用过程遇到的坑(记录ing)
- Android Studio使用Git过程遇到的那些“坑”
- pyspider 使用过程中遇到的一些坑
- Masonry 使用过程中遇到的一些坑
- 记一次RecyclerView使用过程遇到的坑
- spark1.6使用过程中遇到的坑
- 运算符
- openwrt: Makefile 框架分析
- 训练1-4
- C#中 DataGridView 属性说明(转载)
- 如何在 OSX 中開啟多個 Eclipse
- Hibernate使用过程遇到的坑
- qt webview 忽略 ssl错误 ignoreSslErrors
- EJB概述
- _BSMachError: (os/kern) invalid capability(20)
- 编程小练习
- linux tomcat 启动用户修改 root用户改为普通用户启动
- javascript阻止scroll事件多次执行的思路及实现
- php文件及文件夹操作(创建、删除、移动、复制)
- TCP/IP详解(三)---IP、ARP协议