【笔记】IntelliJ IDEA配置Hibernate

参考:imooc:http://www.imooc.com/video/7706

【笔记】IntelliJ IDEA配置Hibernate

1、创建Hibernate的配置文件。

将依赖包导入项目。http://blog.csdn.net/a153375250/article/details/50851049

IntelliJ IDEA配置 Hibernate:https://smiletm.github.io/2016/12/03/IntelliJ-Hibernate/

Add Framework Support配置Hibernate Support:https://www.jetbrains.com/help/idea/2017.1/enabling-hibernate-support.html

可能以后要参考的:http://www.cnblogs.com/flowwind/p/4751984.html

IntelliJ IDEA没有Hibernate的Frameworks support!要下载企业版。http://blog.csdn.net/gnail_oug/article/details/53977118

创建maven项目。

编写pom.xml:

<?xml version = "1.0" encoding = "UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
            http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xkfx.mydao</groupId>
    <artifactId>mydao</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <name>Maven Hello World Project</name>
    <dependencies>
        <!--添加junit依赖-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <!-- 添加Hibernate依赖 -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.2.4.Final</version>
        </dependency>
    </dependencies>
</project>

import change之后,add frameworks support:

【笔记】IntelliJ IDEA配置Hibernate

 后续:https://smiletm.github.io/2016/12/03/IntelliJ-Hibernate/

编辑hibernate.cfg.xml:通过添加数据库自动编辑。(需要下载相应的驱动.jar

2、创建持久化类。

【笔记】IntelliJ IDEA配置Hibernate

hbm详解:http://blog.csdn.net/tuke_tuke/article/details/49717991、http://blog.sina.com.cn/s/blog_7ffb8dd5010144yo.html

根据相应的表创建相应的映射类和hbm映射配置文件,参考:http://www.cnblogs.com/yangyquin/p/5438248.html

参考单词:entity实体、Persistence持久。

创建成功后还需要修改:添加构造器、toString()等。

【笔记】IntelliJ IDEA配置Hibernate