Giter Club home page Giter Club logo

hibernate-table-relationship's Introduction

多表关系映射

目录说明

  • simple: 单表操作,通过 Spring Data JPA 进行 CRUD 操作。
  • one-to-one: 一对一
  • one-to-one-shared-pk: 一对一,子表主外键共享
  • one-to-many: 一对多
  • many-to-many: 多对多
  • many-to-many-extra-columns: 多对多,关联表含扩展字段

以上目录,各自独立。

环境约定

  • JDK 1.8
  • Intellij IDEA (Community Edition)
  • Maven 3.6.0
  • Spring Boot 2.1.4.RELEASE
  • Spring Data JPA, H2, Lombok

数据库

当前使用 H2 内存数据库,配置方式如下:

## jpa settings
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.show-sql=true

如需使用实体数据库,可参考如下:

## datasource settings
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.password=demo
spring.datasource.url=jdbc:h2:tcp://127.0.0.1/~/jpa-h2
spring.datasource.username=demo
## jpa settings
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.show-sql=true

如需使用 H2 Web Console 访问数据库,配置如下:

## datasource settings
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.password=demo
spring.datasource.url=jdbc:h2:mem:jpa-h2
spring.datasource.username=demo
## h2 web console settings
spring.h2.console.enabled=true
## jpa settings
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.show-sql=true

hibernate-table-relationship's People

Contributors

lewis2951 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hibernate-table-relationship's Issues

小白麻烦请教一下。。。

作者你好,我下载了你的项目,运行的时候提示报错。报错信息如截图所示。据我所知,System.out.println()应该没有println(String,String)的方法。想问一下你原来编辑代码的时候可以正常运行吗?麻烦解答一下,谢谢。:)
报错信息

您好,一个关于双向关联的问题

我在运行one-to-one项目时,调用findAll接口,返回的是空。百度的结果是因为双向关联死循环,json解析问题
请问您知道怎么解决么

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.