无需XML的hibernate

本文探讨了如何在不使用XML配置的情况下使用Hibernate进行对象关系映射。通过介绍Hibernate的注解配置,阐述了如何直接在Java类上定义实体和关系,简化了开发流程并提高了效率。
摘要由CSDN通过智能技术生成



/**
 * 
 */
package com.laotou99.test1;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

import com.laotou99.domain.Test1;
import com.laotou99.domain.Test2;

/**
 * @author gjj
 *
 */
public class MainTest1 {

	/**
	 * 
	 */
	public MainTest1() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) { 
		
		Configuration conf = new Configuration()
			.addAnnotatedClass(com.laotou99.domain.Test1.class)
			.addAnnotatedClass(com.laotou99.domain.Test2.class)
			.setProperty("hibernate.connection.driver_class"
				, "com.mysql.jdbc.Driver")
			.setProperty("hibernate.connection.url"
				, "jdbc:mysql://localhost:3306/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值