jpa

How do I query UUIDs stored as binary in a database (JPA/Hibernate/MySQL)

时光怂恿深爱的人放手 提交于 2021-02-07 02:36:52
问题 I have a Java/JPA/Hibernate/MySQL based app. I want to use UUIDs for object identity, however I want to ensure database performance does not suffer. I found this great blog posting JPA and UUID Primary Keys which gets me some of the way there. Notice how the storage of the UUID is optimized by storing it in binary form (versus the string representation. It solves part of the problem, because now we can insert objects efficiently into the database. However, now I have an issue when I want to

JPA - @PreRemove method behaviour

戏子无情 提交于 2021-02-06 20:00:46
问题 I have 2 entities with many-to-many relationship. The Movie Entity is the owner of this relation, so when I want to delete an Actor Entity I use a method annotated @PreRemove to delete any occurrences of Actor ID in Movie cast to avoid "Foreign key violation exception". Movie class @Entity public class Movie extends AbstractBusinessObject{ @ManyToMany private Map<String, Actor> cast; // setters and getters public void removeCastMember(Actor actor){ for (Entry<String, Actor> e : cast.entrySet(

DB administration site for Spring + JPA project

余生颓废 提交于 2021-02-06 12:57:45
问题 I would like to know how if there is any way to automatically generate a database administration site for a Spring + JPA project. It should take the annotated JPA entities and dynamically generate the site to keep track of any change in the domain Java classes. I am looking for something similar to the Django admin site (I think you can also do the same with Ruby on Rails), that allows the user: to see and update the data in the different tables without developing any extra code to handle

Exclude a specific table from being created by hibernate?

﹥>﹥吖頭↗ 提交于 2021-02-06 09:51:30
问题 I have an @Entity which is mapped to a view, here is how it looks import org.hibernate.annotations.Immutable; import javax.persistence.*; @Table(name = "user_earning") @Entity @Immutable public class UserFlightEarning { @Id public Long userId; public Long flightId; @Column(name = "flight_seq") public Long flightSequence; } This works fine, I can retrieve records from the view using the dao. However I noticed in the logs that Hibernate is actually trying to create the table but failing because

Spring data internationalization best practice

 ̄綄美尐妖づ 提交于 2021-02-05 20:11:13
问题 I have a spring mvc project with spring data, jpa and hibernate. I have a multilanguage database. I designed my database and entity. I am looking for a best practice to query my tables by language. Do I have to write custom jpa query, or is there a generic way to query my tables. If I have a mistake on db or entity design, please warn me. Database: CREATE TABLE translation ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)); CREATE TABLE translation_text ( translation_id BIGINT

Spring data internationalization best practice

陌路散爱 提交于 2021-02-05 20:11:01
问题 I have a spring mvc project with spring data, jpa and hibernate. I have a multilanguage database. I designed my database and entity. I am looking for a best practice to query my tables by language. Do I have to write custom jpa query, or is there a generic way to query my tables. If I have a mistake on db or entity design, please warn me. Database: CREATE TABLE translation ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)); CREATE TABLE translation_text ( translation_id BIGINT

Spring data internationalization best practice

有些话、适合烂在心里 提交于 2021-02-05 20:07:04
问题 I have a spring mvc project with spring data, jpa and hibernate. I have a multilanguage database. I designed my database and entity. I am looking for a best practice to query my tables by language. Do I have to write custom jpa query, or is there a generic way to query my tables. If I have a mistake on db or entity design, please warn me. Database: CREATE TABLE translation ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)); CREATE TABLE translation_text ( translation_id BIGINT

What do I need to include in Tomcat 7 to get javax.persistence working correctly?

扶醉桌前 提交于 2021-02-05 11:38:35
问题 I'm attempting to build a JSF/Hibernate application using Java 7 and Tomcat 7. I have installed the Java SDK and the JavaEE SDK, and copied the javaee.jar and javaee-api-6.jar into my Tomcat LIB folder. By my understanding of this post and this post I should have all of the jars I need, and to the best of my knowledge I have no other jars in this folder that have conflicting resources. The javaee.jar file contains what looks like a Maven pom file, and nothing else. I'm not sure what its value

What do I need to include in Tomcat 7 to get javax.persistence working correctly?

旧城冷巷雨未停 提交于 2021-02-05 11:38:24
问题 I'm attempting to build a JSF/Hibernate application using Java 7 and Tomcat 7. I have installed the Java SDK and the JavaEE SDK, and copied the javaee.jar and javaee-api-6.jar into my Tomcat LIB folder. By my understanding of this post and this post I should have all of the jars I need, and to the best of my knowledge I have no other jars in this folder that have conflicting resources. The javaee.jar file contains what looks like a Maven pom file, and nothing else. I'm not sure what its value

How to fix “java.sql.SQLException: Column 'id' not found.” error in Spring Boot

一曲冷凌霜 提交于 2021-02-05 11:34:29
问题 There are 2 entities: Deck and Card. Each Deck contains 8 out of 100 possible Cards. Since each Deck contains more than one Card and the Card can also be part of many different Decks, I joined them by creating a new table called deck_cards. @Data @Entity @Table(name = "cards") public class Card { @Id private Integer id; @NotBlank private String icon; @NotBlank private String name; @ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "cards")