hibernate

文献综述五:商品管理系统

China☆狼群 提交于 2021-02-03 06:44:41
一、基本信息   <font color="#0099ff">标题</font>:商品管理系统   <font color="#0099ff">时间</font>:2015   <font color="#0099ff">出版源</font>:信息技术与信患化   <font color="#0099ff">文件分类</font>:商品管理系统的研究 二、研究背景   研究基于 Java 的Hibernate 、JSP 平 台和数据库 oracIe的商品管理系统。 三、具体内容   一开头就介绍了jsp,oracle以及tomcat等开发工具,使用了一些框架如,hiberbate和struts2。同时,还给我们介绍了其运行环境。最重要的部分就是总体设计。总体设计包括功能模块 图设计和数据库设计。   <font color="#0099ff">1.功能模块图设计</font>:如图所示。主要分为前台和后台。大部分的功能都是在后台。   <font color="#0099ff">2.数据库设计</font>:分为商品类别表,菜单信息表以及角色表。   <font color="#0099ff">3.功能实现</font>:有对角色、商品管理和商品类别的添加,删除,修改功能。   还提到了系统的目录结构。如下图所示。    四、结论   <font color="#0099ff"

(一)MyBatis从入门到入土——简介

微笑、不失礼 提交于 2021-02-02 20:03:08
这是MyBatis系列第1篇。大概会用十三篇的篇幅来讲解MyBatis,喜欢这个系列的欢迎关注公众号【Java冢狐】获取最新文章。那么废话不多说,让我们开始吧! 没有MyBatis的时代 要说起MyBatis,那要从还没有MyBatis的时代的时候说起。那个时候我们进行数据库开发的,大多使用jdbc来进行。但是JDBC的操作数据库用起来真的是头大。十分的繁琐和无聊,很容易出现问题和错误。其中具体的情况如下所示: JDBC时代 连接使用数据库的过程: 加载驱动 获取连接 拼接sql 执行sql 获取结果 解析结果 关闭数据库 上面这些操作都是我们使用jdbc连接数据库的时候必须经过的过程。可以看出步骤十分的繁琐,关键是这些步骤中很多都不是我们程序员真正关心的,我们程序员真正关心的只有拼接sql、执行sql和解析结果。 但是基于JDBC得框架下,其他的操作又不得不去编写和操作,使得我们在代码编写上十分的吃力和冗余,对于程序员来说不是特别的友好。 JDBC缺点 正如上面所说的,JDBC有着一些很致命的缺点,总体来说有一下几个方面: 重复代码过多 每个操作耗时过多 调试维护麻烦 动态sql方面没有规范,难以维护 正是因为JDBC有着一些致命的缺点才导致我们使用其他的框架来完成与数据库的交互,诸如Hibernate和MyBatis就是其中比较好的代表。 Hibernate

hibernate criteria count over with group by

本秂侑毒 提交于 2021-02-02 09:37:26
问题 I have a spring app with the user entity and the users table. I would like to get a number of all users grouped by certain fields (not per group but in total ). In sql It would be: select count(*) OVER () as totalRecords from users u group by u.first_name, u.last_name, u.age order by u.age DESC OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY; But I really can't do that using hibernate criteria. I could do something like: public Long getTotalCount() { ProjectionList groupBy = projectionList(); groupBy

hibernate criteria count over with group by

做~自己de王妃 提交于 2021-02-02 09:35:52
问题 I have a spring app with the user entity and the users table. I would like to get a number of all users grouped by certain fields (not per group but in total ). In sql It would be: select count(*) OVER () as totalRecords from users u group by u.first_name, u.last_name, u.age order by u.age DESC OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY; But I really can't do that using hibernate criteria. I could do something like: public Long getTotalCount() { ProjectionList groupBy = projectionList(); groupBy

hibernate criteria count over with group by

北战南征 提交于 2021-02-02 09:31:33
问题 I have a spring app with the user entity and the users table. I would like to get a number of all users grouped by certain fields (not per group but in total ). In sql It would be: select count(*) OVER () as totalRecords from users u group by u.first_name, u.last_name, u.age order by u.age DESC OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY; But I really can't do that using hibernate criteria. I could do something like: public Long getTotalCount() { ProjectionList groupBy = projectionList(); groupBy

How to represent Oracle Interval in Java

…衆ロ難τιáo~ 提交于 2021-02-02 09:15:27
问题 I'm using Java 7 with hibernate 4. Want to use oracle Interval data type (http://psoug.org/definition/INTERVAL.htm) to represent a interval of a certain number of days. Wondering what Java Type to use to map this Oracle Interval Object. I would like to use standard Java objects and not any oracle.sql.* objects as mentioned in this document http://docs.oracle.com/cd/B28359_01/java.111/b31224/datacc.htm. Here's the table I'm playing with: CREATE TABLE "MyTest" ( "ID" NUMBER(14,0) NOT NULL

Hibernate: Delete all children with one query

时间秒杀一切 提交于 2021-02-02 08:56:38
问题 TL;DR: Is it possible to configure Hibernate to delete all child objects using a single delete query? Full Question: I have the following parent/child association defined in Hibernate 5.1: public class Parent { @OneToMany(fetch = FetchType.EAGER, mappedBy = "parent", cascade = CascadeType.REMOVE) private List<Child> children; } public class Child { @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "parent_id", nullable = false) private Parent parent; } When I delete the parent object,

Will hibernate increment version if I add/remove/update element of dependable collection?

蹲街弑〆低调 提交于 2021-01-29 22:19:20
问题 I am learning hibernate optimistic lock mechanism and I haven't found answer on my question in user guide Let's say we have entity like this: @Entity class Employee{ @Version Long versionField; List<Employee> subordinates; ... } And somewhere we have following code: Employee sub = .... Emplyee emp = readEmploye(); emp.getSubordinates().add(sub); Can I control of version incrementation at this case ? 回答1: By default no. Since you're not changing the entity, but rather other entities that are

Hibernate Unable to load class []

人走茶凉 提交于 2021-01-29 21:37:37
问题 I recently added a few features (connecting database tables to other tables) using JPA (with hibernate). It worked fine before, but now I'm getting the exception org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [] - or at least I think that's the most relevant part of it. The whole exception is: org.apache.tapestry5.ioc.internal.OperationException: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc

Will hibernate increment version if I add/remove/update element of dependable collection?

人走茶凉 提交于 2021-01-29 21:28:14
问题 I am learning hibernate optimistic lock mechanism and I haven't found answer on my question in user guide Let's say we have entity like this: @Entity class Employee{ @Version Long versionField; List<Employee> subordinates; ... } And somewhere we have following code: Employee sub = .... Emplyee emp = readEmploye(); emp.getSubordinates().add(sub); Can I control of version incrementation at this case ? 回答1: By default no. Since you're not changing the entity, but rather other entities that are