hibernate
qq_26847293
这个作者很懒,什么都没留下…
展开
-
Hibernate named query examples
Often times, developer like to put HQL string literals scatter all over the Java code, this method is hard to maintaine and look ugly. Fortunately, Hibernate come out a technique called “names queries”转载 2015-09-16 11:45:13 · 410 阅读 · 0 评论 -
Hibernate parameter binding examples
Without parameter binding, you have to concatenate the parameter String like this (bad code) :String hql = "from Stock s where s.stockCode = '" + stockCode + "'";List result = session.createQuery(hql)转载 2015-09-16 11:09:02 · 476 阅读 · 0 评论 -
HIbernate commit() and flush()
I googled a lot and read about org.hibernate.Transaction.commit() and org.hibernate.Session.flush() a lot, know purpose of each method, but still have a question.Is it good practice to call org.hiberna转载 2015-09-16 13:43:36 · 389 阅读 · 0 评论 -
What will happen if we begin transaction in hibernate but do not commit it?
What will happen if we begin transaction in hibernate, then do some transaction but do not commit it? Will it save tempervoraly or it will rollback immediately?Look at the following code, which accesse转载 2015-09-16 10:08:08 · 560 阅读 · 0 评论 -
BeginTransaction Hibernate necessary?
Is it really necessary to start a transaction when you are going to execute only one query, without deleting or updating data? I’m currently using Hibernate 4.1.9 with C3p0Example,session session = hi转载 2015-09-16 09:48:19 · 297 阅读 · 0 评论 -
Maven 3 + Hibernate 3.6 + Oracle 11g Example (XML Mapping)
In this article, we show you how to integrate Maven3, Hibernate3.6 and Oracle11g together. In the end of this article, you will create a Java project with Maven, and insert a record into Oracle databas转载 2015-09-16 09:43:39 · 591 阅读 · 0 评论 -
Maven 2 + Hibernate 3.2 + MySQL Example (Annotation)
This tutorial will modify the previous Maven 2 + Hibernate 3.2 + MySQL Example (XML mapping), and replace the Hibernate XML mapping file with Annotation code.Tools & technologies used in this article :转载 2015-09-16 09:32:28 · 287 阅读 · 0 评论 -
Maven 2 + Hibernate 3.2 + MySQL Example (Annotation)
This tutorial will modify the previous Maven 2 + Hibernate 3.2 + MySQL Example (XML mapping), and replace the Hibernate XML mapping file with Annotation code.Tools & technologies used in this article :转载 2015-09-16 09:32:23 · 263 阅读 · 0 评论 -
Multi-Column Join in Hibernate/JPA Annotations
I have two entities which I would like to join through multiple columns. These columns are shared by an @Embeddable object that is shared by both entities. In the example below, Foo can have only one B转载 2015-09-08 12:46:41 · 585 阅读 · 0 评论 -
How to use Hibernate annotations @ManyToOne and @OneToMany for associations
I need to make one-to-many relationship (one Employee have many Tasks). I have tried many examples but still can’t get idea how to make my code work:Employee.java:package com.giantflyingsaucer.simplesp转载 2015-09-08 15:26:09 · 328 阅读 · 0 评论 -
spring对session和事务的管理以及OpenSessionInViewFilter是如何工作的
为了弄清楚spring对session和事务的管理以及OpenSessionInViewFilter是如何工作的,可监控以下类的日志:org.springframework.orm.hibernate3.HibernateTransactionManager,org.hibernate.transaction.JDBCTransaction,org.hibernate.impl.SessionI转载 2015-09-11 10:54:30 · 423 阅读 · 0 评论 -
How to embed Oracle hints in Hibernate query
With Oracle hints, you can alter the Oracle execution plans to affect the way how Oracle retrieve the data from database. In Hibernate, is this possible to embed the Oracle hint into the Hibernate quer转载 2015-09-16 11:18:21 · 568 阅读 · 0 评论 -
Hibernate Criteria examples
Hibernate Criteria API is a more object oriented and elegant alternative to Hibernate Query Language (HQL). It’s always a good solution to an application which has many optional search criteria.Example转载 2015-09-16 11:30:57 · 448 阅读 · 0 评论 -
Hibernate Query examples (HQL)
Hibernate created a new language named Hibernate Query Language (HQL), the syntax is quite similar to database SQL language. The main difference between is HQL uses class name instead of table name, an转载 2015-09-16 10:55:55 · 376 阅读 · 0 评论 -
Hibernate – The type AnnotationConfiguration is deprecated
ProblemWorking with Hibernate 3.6, noticed the previous “org.hibernate.cfg.AnnotationConfiguration“, is marked as “deprecated“.Code snippets …import org.hibernate.cfg.AnnotationConfiguration;//...pri转载 2015-09-16 10:51:36 · 1081 阅读 · 0 评论 -
Maven 3 + Hibernate 3.6 + Oracle 11g Example (Annotation)
This tutorial will reuse and modify the previous Hibernate3.6 XML mapping tutorial, but replace the Hibernate mapping file (hbm) with Hibernate / JPA Annotation code.Technologies in this article :Mave转载 2015-09-16 10:49:03 · 420 阅读 · 0 评论 -
How to add Oracle JDBC driver in your Maven local repository
Due to Oracle license restriction, there is NO public Maven repository provides Oracle JDBC driver. To use Oracle jdbc drive with Maven, you have to install it manually into your Maven local repository转载 2015-09-16 10:44:58 · 679 阅读 · 0 评论 -
How to generate Hibernate mapping files & annotation with Hibernate Tools
In this article, we show you how to use Hibernate / JBoss Tools to generate Hibernate mapping files (hbm) and annotation code from database automatically.Tools in this articleEclipse v3.6 (Helios)JBo转载 2015-09-16 10:39:26 · 844 阅读 · 0 评论 -
hibernate begintransaction throwing exception
I am a newbie to hibernate. Please let me know what is wrong in the below code ?f1(){ try { s = HibernateUtils.getSessionFactory().getCurrentSession(); tx = s.beginTransaction();转载 2015-09-16 10:12:18 · 353 阅读 · 0 评论 -
conn.setAutoCommit(true)和(false)的区别
默认的话为自动提交, 每执行一个update ,delete或者insert的时候都会自动提交到数据库,无法回滚事务。 设置connection.setautocommit(false);只有程序调用connection.commit()的时候才会将先前执行的语句一起提交到数据库,这样就实现了数据库的事务。true:sql命令的提交(commit)由驱动程序负责 false:sql命令的提交由转载 2015-09-16 10:09:35 · 21019 阅读 · 1 评论 -
can begin transaction in hibernate called while commiting/rollback
Will the below code works fine or do I need to begin transaction before doing work.Session session = SessionFactory.openSession();//do some work like session.save/Updatefinally{ session.beginTransa转载 2015-09-16 09:52:53 · 332 阅读 · 0 评论 -
Maven 2 + Hibernate 3.2 + MySQL Example (XML Mapping)
This quick guide show you how to use Maven to generate a simple Java project, and uses Hibernate to insert a record into MySQL database.Tools & technologies used in this article :Maven 2.2.1JDK 1.6.0转载 2015-09-16 09:18:20 · 328 阅读 · 0 评论 -
Hibernate native SQL queries examples
In Hibernate, HQL or criteria queries should be able to let you to execute almost any SQL query you want. However, many developers are complaint about the Hibernate’s generated SQL statement is slow an转载 2015-09-16 11:33:31 · 317 阅读 · 0 评论 -
Hibernate一对多和多对一关系详解
双向一对多关系,一是关系维护端(owner side),多是关系被维护端(inverse side)。在关系被维护端需要通过@JoinColumn建立外键列指向关系维护端的主键列。publicclass Order implements Serializable { privateSet<OrderItem> orderItems = new HashSet<OrderItem>();转载 2015-09-07 16:52:48 · 302 阅读 · 0 评论 -
Maven 2 + Hibernate 3.2 + MySQL Example (XML Mapping)
This quick guide show you how to use Maven to generate a simple Java project, and uses Hibernate to insert a record into MySQL database.Tools & technologies used in this article :Maven 2.2.1JDK 1.6.0转载 2015-09-07 10:47:40 · 464 阅读 · 0 评论 -
Hibernate – One-to-Many example (XML Mapping)
A one-to-many relationship occurs when one entity is related to many occurrences in another entity. In this tutorial, we show you how to works with one-to-many table relationship in Hibernate, via XML转载 2015-09-07 11:19:42 · 344 阅读 · 0 评论 -
hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
1.日期:@Temporal(TemporalType.DATE) @Column(name = "applyDate", nullable = false, length = 10) public Date getApplyDate() { return applyDate; }在页面端取值:2011-04-122.时间:@Temporal(TemporalType.TIME)在页面端取转载 2015-09-09 10:22:57 · 674 阅读 · 0 评论 -
文章标题
A tutorial to show how to integrate Hibernate with in a web application developed with Apache Struts 1.x.Steps of the integration :Create a new Hibernate Struts plug-in file to set the Hibernate sessio转载 2015-09-09 10:20:44 · 279 阅读 · 0 评论 -
Hibernate @ManyToOne Unidirectional Tutorial
In the past we have learned about database relationships, specifically the One-to-Many as well as the Many-to-Many and One-to-One and that was all good, great and grand…But now I want to talk about how转载 2015-09-09 10:02:06 · 409 阅读 · 0 评论 -
add more columns in join table using spring, hibernate, JPA Annotations
Can we add more columns in a join table annotation? Generally I see people ending up with adding two columns as shown in the below example.@JoinTable(name="mapping_table", joinColumns={@转载 2015-09-08 11:15:40 · 495 阅读 · 0 评论 -
Mapping a bidirectional list with Hibernate
I don’t understand the behavior of Hibernate when mapping a bidirectional list. The SQL statements that Hibernate produces seem not optimal to me. Can somebody enlighten me?The scenario is the followin转载 2015-09-07 17:30:58 · 332 阅读 · 0 评论 -
JPA JoinColumn vs mappedBy
What is the difference between:@Entitypublic class Company { @OneToMany(cascade = CascadeType.ALL , fetch = FetchType.LAZY) @JoinColumn(name = "companyIdRef", referencedColumnName = "companyId"转载 2015-09-07 17:22:22 · 515 阅读 · 0 评论 -
hibernate中一对多关系的映射
一、一对多的关系映射建立一对多关系表的原则是将一的一方的主键加入到多的一方的表作为外键。这里以员工和部门为例子来演示。以前不用hibernate时建立pojo类要在员工类Emp中加入一个属性,即部门编号deptid.使用hibernate则不同了,需要在“一”的一方类中加入一个set集合,里面存放“多”的一方的对象。而在“多”的一方的类中需要加入一个“一”方的对象。也就是说在Dept类中需要加入一个转载 2015-09-07 16:59:07 · 291 阅读 · 0 评论 -
Hibernate一对多(双向)
双向关联就是有“一对多”和“多对一”两个关联组合而成,在双向关联的两端都知道对方是谁。 首先定义我们需要使用的POJO对象。 public class Member { private String id; private String name; private Integer age;转载 2015-09-07 16:44:37 · 277 阅读 · 0 评论 -
Please explain about: insertable=false, updatable=false
If a field is annotated insertable=false, updatable=false, doesnt it mean that you cannot insert value nor change the existing value? Why would u want to do that?Do you mean something like this BalusC?转载 2015-09-08 16:29:28 · 953 阅读 · 0 评论 -
Bidirectional @OneToMany / @ManyToOne association
One of goals the in programming is representation of models from the real world. Very often an application needs to model some relationship between entities. In the last article about Hibernate associa转载 2015-09-08 10:57:49 · 301 阅读 · 0 评论 -
Hibernate – One-to-One example (XML Mapping)
A one-to-one relationships occurs when one entity is related to exactly one occurrence in another entity. In this tutorial, we show you how to work with one-to-one table relationship in Hibernate, via转载 2015-09-09 09:40:09 · 313 阅读 · 0 评论 -
How to configure DBCP connection pool in Hibernate
Note Due to bugs in the old DBCP code, Hibernate is no longer maintain DBCP-based connection provider, read this Hibernate thread. Now, Apache DBCP is back to active development, and many bugs ar转载 2015-09-09 10:14:07 · 589 阅读 · 0 评论 -
Hibernate – One-to-One example (XML Mapping)
A one-to-one relationships occurs when one entity is related to exactly one occurrence in another entity. In this tutorial, we show you how to work with one-to-one table relationship in Hibernate, via转载 2015-09-07 11:04:16 · 279 阅读 · 0 评论 -
Hibernate学习之一对多关联
注意事项: 1.单向一对多 只需在“一”放进行配置 2.双向一对多 需要在关联双方都加以配置,而且需要在一的一方设置inverse=true首先是实体类:TAddress.java(多的一方)public class TAddress implements Serializable { private static final long serialVersionUID =转载 2015-09-07 16:38:10 · 225 阅读 · 0 评论