hibernate

Hibernate restore soft-deleted entity

妖精的绣舞 提交于 2020-12-07 05:03:13
问题 I have an entity @Entity @Table(name = "[Usermaster]") @SQLDelete(sql = "UPDATE Usermaster SET isDeleted = 1") @Where(clause = "isDeleted = 0") public class User { //... } Now when I delete some Entity it actually will set deleteFlag = 1 How can I restore the entity? thanks 来源: https://stackoverflow.com/questions/24656518/hibernate-restore-soft-deleted-entity

Hibernate's PersistentSet not using custom implementations of hashCode/equals

跟風遠走 提交于 2020-12-06 07:49:11
问题 So I have an entity Book public class Book { private String id; private String name; private String description; private Image coverImage; private Set<Chapter> chapters; //Sets & Gets @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Book)) return false; Book book = (Book) o; return Objects.equals(name, book.name) && Objects.equals(description, book.description) && Objects.equals(image, book.image) && Objects.equals(chapters, book.chapters); }

Hibernate's PersistentSet not using custom implementations of hashCode/equals

我们两清 提交于 2020-12-06 07:49:08
问题 So I have an entity Book public class Book { private String id; private String name; private String description; private Image coverImage; private Set<Chapter> chapters; //Sets & Gets @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Book)) return false; Book book = (Book) o; return Objects.equals(name, book.name) && Objects.equals(description, book.description) && Objects.equals(image, book.image) && Objects.equals(chapters, book.chapters); }

Cannot import javax.validation.constraints in IntelliJ IDEA

岁酱吖の 提交于 2020-12-06 05:51:15
问题 I can't import that simple library, i have all jar files, also i tried Ivalidate Caches / Restart. Maybe i have to add validation to build path, but i don't know to which file. 回答1: Got it. File -> Project Structure In Modules click Dependecies, then click green "+" on the right side Click JARs or directiories... and add JAR files Click OK THEN: File -> Project Structure In Artifacts click FIX button on right bottom size Click OK 回答2: What build tool do you use? You obviously forgot to

Cannot import javax.validation.constraints in IntelliJ IDEA

試著忘記壹切 提交于 2020-12-06 05:51:09
问题 I can't import that simple library, i have all jar files, also i tried Ivalidate Caches / Restart. Maybe i have to add validation to build path, but i don't know to which file. 回答1: Got it. File -> Project Structure In Modules click Dependecies, then click green "+" on the right side Click JARs or directiories... and add JAR files Click OK THEN: File -> Project Structure In Artifacts click FIX button on right bottom size Click OK 回答2: What build tool do you use? You obviously forgot to

韩顺平 spring 笔记 第一讲

自古美人都是妖i 提交于 2020-12-06 04:54:58
1、spring 是什么?   struts 是web框架(php/action/actionform)   hibernate是orm框架(对象和关系映射的框架,处于持久层)   spring是容器框架,用于配置bean并维护bean之间关系的框架   bean(是java中的任何一种对象 javabean/service/action/数据源/dao)roc(控制反转)di(依赖注入) 2、开发一个Spring项目   (1)引入Spring的开发包,最小配置Spring.jar,该包把常用的jar都包括,还要写日志包commons-logging.jar   创建spring的一个核心文件 applicationContext.xml(hibernate有核心文件hibernate.cfg.xml)   (2)struts核心文件struts.config.xml 该文件一般就在src目录下   (3)在容器文件中配置bean(service/dao/daomain/action/数据源)     <!--bean元素的作用是,当我们的spring框架加载时候,spring就会自动的创建一个bean对象,并放入内存 相当于UserService userService=new UserService()-->   <bean id="userService" class=

JPA Query Returning Same Result for different Parameter

偶尔善良 提交于 2020-12-05 11:58:29
问题 I'm running into an issue where my query method is in a foreach loop, and each time I'm passing in a different parameter to retrieve different information. However, after the FIRST iteration of the loop, the query data gets cached (I think) and returns the same data for subsequent loops. Here is my code: @Transactional(readOnly = true) public List<InitiativeReport> getInitiativeReports() throws Exception { try { List<InitiativeReport> ir = new ArrayList<InitiativeReport>(); List<Initiative>

how to map between two tables with @EmbeddedId s?

喜欢而已 提交于 2020-12-05 11:54:26
问题 So what I have here is a diagram that looks like this, which can be found in this Answer Here. +---------------+ +-------------------+ | PRODUCTS |-----< PRODUCT_VARIANTS | +---------------+ +-------------------+ | #product_id | | #product_id | | product_name | | #variant_id | +---------------+ | sku_id | | +-------------------+ | | +--------^--------+ +--------^--------+ | PRODUCT_OPTIONS |-----< VARIANT_VALUES | +-----------------+ +-----------------+ | #product_id | | #product_id | |

how to map between two tables with @EmbeddedId s?

半城伤御伤魂 提交于 2020-12-05 11:53:51
问题 So what I have here is a diagram that looks like this, which can be found in this Answer Here. +---------------+ +-------------------+ | PRODUCTS |-----< PRODUCT_VARIANTS | +---------------+ +-------------------+ | #product_id | | #product_id | | product_name | | #variant_id | +---------------+ | sku_id | | +-------------------+ | | +--------^--------+ +--------^--------+ | PRODUCT_OPTIONS |-----< VARIANT_VALUES | +-----------------+ +-----------------+ | #product_id | | #product_id | |

how to do a JOIN FETCH in jpa criteria

冷暖自知 提交于 2020-12-05 10:30:06
问题 I am trying to translate the query below to criteria api. SELECT er from ereturn er JOIN FETCH product_item pi ON pi.ereturn_id = er.id WHERE pi.status = "RECEIVED" To something like this: CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Ereturn> criteria = builder.createQuery( Ereturn.class ); Root<Ereturn> er = criteria.from(Ereturn.class); Join<Ereturn, ProductItem> productItemJoin = er.join("productItems", JoinType.LEFT); Fetch<Ereturn, ProductItem> productItemFetch = er