3+2*0+6=?

《微观经济学》 2_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
《微观经济学》 2
阅读已结束,下载文档到电脑
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,方便使用
还剩5页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
下载作业帮安装包
扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
用简便方法计算:(1)0.3+0.6+1.2+2.4+4.8+9.6+19.2(2)0.26*9.8-0.74*0.2
扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
  (1)原式=0.3+0.6+1.2+2.4+4.8+9.6+19.2  =0.3(1+2+4+8+16+32+64)  =0.3*127  =38.1  (2)原式=0.26*(10-0.2)-(1-0.26)*0.2  =2.6-0.2*0.26-(0.2-0.2*0.26)  =2.6-0.2*0.26-0.2+0.2*0.26  =2.6-0.2  =2.4
为您推荐:
其他类似问题
扫描下载二维码Maven 2 + Hibernate 3.2 + MySQL Example (Annotation)
| December 30, 2009 | Updated : August 30, 2012 | Viewed : 189,196 times +440 pv/w
This article is outdated, and some information is no longer valid in latest Hibernate development. You should refer to this latest –
This tutorial will modify the previous , and replace the Hibernate XML mapping file with Annotation code.
Tools & technologies used in this article :
Maven 2.2.1
JDK 1.6.0_13
Hibernate 3.2.3.GA
1. Create project infrastructure
Create project infrastructure in
2. Add JBoss
repository
JBoss repository in pom.xml is required to download the Hibernate annotation library.
&repositories&
&repository&
&id&JBoss repository&/id&
&url&/maven2/&/url&
&/repository&
&/repositories&
3. Add Hibernate annotation dependency
Add hibernate-annotations and hibernate-commons-annotations dependency in pom.xml.
&dependency&
&groupId&hibernate-annotations&/groupId&
&artifactId&hibernate-annotations&/artifactId&
&version&3.3.0.GA&/version&
&/dependency&
&dependency&
&groupId&hibernate-commons-annotations&/groupId&
&artifactId&hibernate-commons-annotations&/artifactId&
&version&3.0.0.GA&/version&
&/dependency&
File : pom.xml
&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/maven-v4_0_0.xsd"&
&modelVersion&4.0.0&/modelVersion&
&groupId&mon&/groupId&
&artifactId&HibernateExample&/artifactId&
&packaging&jar&/packaging&
&version&1.0-SNAPSHOT&/version&
&name&HibernateExample&/name&
&url&http://maven.apache.org&/url&
&repositories&
&repository&
&id&JBoss repository&/id&
&url&/maven2/&/url&
&/repository&
&/repositories&
&dependencies&
&!-- MySQL database driver --&
&dependency&
&groupId&mysql&/groupId&
&artifactId&mysql-connector-java&/artifactId&
&version&5.1.9&/version&
&/dependency&
&!-- Hibernate core --&
&dependency&
&groupId&hibernate&/groupId&
&artifactId&hibernate3&/artifactId&
&version&3.2.3.GA&/version&
&/dependency&
&!-- Hibernate annotation --&
&dependency&
&groupId&hibernate-annotations&/groupId&
&artifactId&hibernate-annotations&/artifactId&
&version&3.3.0.GA&/version&
&/dependency&
&dependency&
&groupId&hibernate-commons-annotations&/groupId&
&artifactId&hibernate-commons-annotations&/artifactId&
&version&3.0.0.GA&/version&
&/dependency&
&!-- Hibernate library dependecy start --&
&dependency&
&groupId&dom4j&/groupId&
&artifactId&dom4j&/artifactId&
&version&1.6.1&/version&
&/dependency&
&dependency&
&groupId&commons-logging&/groupId&
&artifactId&commons-logging&/artifactId&
&version&1.1.1&/version&
&/dependency&
&dependency&
&groupId&commons-collections&/groupId&
&artifactId&commons-collections&/artifactId&
&version&3.2.1&/version&
&/dependency&
&dependency&
&groupId&cglib&/groupId&
&artifactId&cglib&/artifactId&
&version&2.2&/version&
&/dependency&
&!-- Hibernate library dependecy end --&
&dependency&
&groupId&javax.transaction&/groupId&
&artifactId&jta&/artifactId&
&version&1.1&/version&
&/dependency&
&/dependencies&
&/project&
4. Update project classpath
Issue “mvn eclipse:eclipse” in command prompt to download the dependency library and update the Eclipse’s project classpath.
5. Update HibernateUtil.java
Update “HibernateUtil” to use “AnnotationConfiguration” instead of “Configuration” to build the Hibernate session factory.
Previously is using “Configuration” – For Hibernate XML mapping file
return new Configuration().configure().buildSessionFactory();
Change it to “AnnotationConfiguration” – For Hibernation annotation support
return new AnnotationConfiguration().configure().buildSessionFactory();
File : HibernateUtil.java
package com.mkyong.
import org.hibernate.SessionF
import org.hibernate.cfg.AnnotationC
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
// Create the SessionFactory from hibernate.cfg.xml
return new AnnotationConfiguration().configure().buildSessionFactory();
catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
public static SessionFactory getSessionFactory() {
return sessionF
public static void shutdown() {
// Close caches and connection pools
getSessionFactory().close();
6. Update Model class
Update “Stock.java” to use annotation as follow :
Stock.java
import javax.persistence.C
import javax.persistence.E
import javax.persistence.GeneratedV
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.T
import javax.persistence.UniqueC
@Table(name = "stock", catalog = "mkyong", uniqueConstraints = {
@UniqueConstraint(columnNames = "STOCK_NAME"),
@UniqueConstraint(columnNames = "STOCK_CODE") })
public class Stock implements java.io.Serializable {
private Integer stockId;
private String stockC
private String stockN
public Stock() {
public Stock(String stockCode, String stockName) {
this.stockCode = stockC
this.stockName = stockN
@GeneratedValue(strategy = IDENTITY)
@Column(name = "STOCK_ID", unique = true, nullable = false)
public Integer getStockId() {
return this.stockId;
public void setStockId(Integer stockId) {
this.stockId = stockId;
@Column(name = "STOCK_CODE", unique = true, nullable = false, length = 10)
public String getStockCode() {
return this.stockC
public void setStockCode(String stockCode) {
this.stockCode = stockC
@Column(name = "STOCK_NAME", unique = true, nullable = false, length = 20)
public String getStockName() {
return this.stockN
public void setStockName(String stockName) {
this.stockName = stockN
7. Delete existing Hibernate XML mapping file
Delete existing Hibernate XML mapping file – “Stock.hbm.xml”, this is no longer require.
8. Update Hibernate configuration file
Update the Hibernate configuration file – hibernate.cfg.xml.
Previously it had the Hibernate XML mapping file with “mapping resource” tag
&mapping resource="com/mkyong/common/Stock.hbm.xml"&&/mapping&
Change it to model class with “mapping class” tag
&mapping class="mon.Stock"&&/mapping&
File : hibernate.cfg.xml
&?xml version="1.0" encoding="utf-8"?&
&!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&
&hibernate-configuration&
&session-factory&
&property name="hibernate.bytecode.use_reflection_optimizer"&false&/property&
&property name="hibernate.connection.driver_class"&com.mysql.jdbc.Driver&/property&
&property name="hibernate.connection.password"&password&/property&
&property name="hibernate.connection.url"&jdbc:mysql://localhost:3306/mkyong&/property&
&property name="hibernate.connection.username"&root&/property&
&property name="hibernate.dialect"&org.hibernate.dialect.MySQLDialect&/property&
&property name="show_sql"&true&/property&
&mapping class="mon.Stock"&&/mapping&
&/session-factory&
&/hibernate-configuration&
9. Review project structure
Sound like few files were modified, review it and make sure the folder structure as follow :
10. Run it and see output
Run your App.java, it will insert a new record into “Stock” table. The result should be same with previous Hibernate XML mapping file example.
Maven + Hibernate + MySQL
Hibernate: insert into mkyong.stock (STOCK_CODE, STOCK_NAME) values (?, ?)
Download it –
Share this article on
About the Author
Founder of , love Java and open source stuff. Follow him on , or befriend him on
or . If you like my tutorials, consider make a donation to .
Related Posts
Popular Posts
Loading...
Sort by: &
| most voted}

我要回帖

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信