使用Hibernate和Spring-mvc开发后台程序 与数据库交互

Hibernate, spring-mvc, 数据库mysql 数据管理
摘要由CSDN通过智能技术生成

**

1\

**entity – bean object — project initiating needs them
init failed may caused by the attribute member
cant be find in the table.(data type )
属性对应table属性 use object save needs this, or you can’t find the revelent attribute name in table


-表内容 ,主键自增长
表的内容
直接使用session.save(object),属性与表头不统一,报错,
在这里插入图片描述

you need to label the key, and its generator
see more at hibernate注解主键生成策略(https://www.cnblogs.com/ph123/p/5692194.html)

可以看出JPA提供的四种标准用法为TABLE,SEQUENCE,IDENTITY,AUTO.

TABLE:使用一个特定的数据库表格来保存主键。
SEQUENCE:根据底层数据库的序列来生成主键,条件是数据库支持序列。
IDENTITY:主键由数据库自动生成(主要是自动增长型)
AUTO:主键由程序控制。

在这里插入图片描述
getters and setter, toString()
**

2\

**dao – method impl

@Repository
public class RecipeDao {
   

	@Resource
	private SessionFactory sessionFactory;
	
	//method implement here
}

**

3\

**service – cite dao as a member attribute, encase the method in dao.

@Service
public class RecipeService {
   
	@Resource
	private RecipeDao recipeDao;
	
	//getMenu List  sort{recipeName} 
	public Map<String ,ArrayList<Str
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值