小编A P*_*A P的帖子

Spring Boot + Hibernate一对一映射

我需要一个关于两个表上的CRUD操作的示例,使用一对一映射

休眠.

我想了解如何在Spring Boot中完成此操作.

我已经提到了[这] [1]

链接,但它只显示一个表.

如果有人有这样的链接到网站/ github,它将是非常有帮助的.

提前致谢

我的工作代码

/////////////////////////主要应用/////////////////////// ///////

package com;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.web.SpringBootServletInitializer;

@SuppressWarnings("deprecation")
@SpringBootApplication
public class SpringBootWeb1Application extends SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(SpringBootWeb1Application.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

////////////////////////////////的IndexController ///////////////// ///

package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @RequestMapping("/")
    String index(){
        return "index";
    }
}
Run Code Online (Sandbox Code Playgroud)

//////////////////////// PersonController ///////////////////

package com.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;


import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


import com.model.Person;
import com.service.PersonService; …
Run Code Online (Sandbox Code Playgroud)

hibernate spring-boot

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

标签 统计

hibernate ×1

spring-boot ×1