hibernate-mapping

Hibernate: point foreign_key of table to secondary table

本小妞迷上赌 提交于 2019-12-13 06:15:04
问题 I have three classes: PlanItem Task SubTask It has the following hierachy: public abstract class PlanItem {...} public class Task extends PlanItem { ... private Set<SubTask> subTasks; ... } public class SubTask {...} I am using hibernate to generate three tables: "PlanItem", "Task" and "SubTask". @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public abstract class PlanItem { @Id private String id; } @Entity @SecondaryTable( name = "Task" ) public class Task extends PlanItem {

Hibernate returns null hql in query with @ManyToOne

孤街浪徒 提交于 2019-12-13 05:55:58
问题 First I apologize if my question seems a bit amateurish, but my knowledge with hibernate / jpa and mysql are somewhat limited. Well, I have the following entity: User Entity @Entity @Table(name = "user") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_user") private Long idUser; @Column(nullable = false) private String name; @Column(nullable = false) private String email; @ManyToOne(optional = true, fetch = FetchType.EAGER) @JoinColumn(name = "level"

Get if a user is following element in a query with JPA / Hibernate

旧街凉风 提交于 2019-12-13 04:19:46
问题 In a spring boot + JPA applition, I have a user table and a item table with a ManyToMany relationship. The users can "follow" any Item element, in a twitter/facebook style to get the posts related to that item, get notificacions when an item change, etc. The classes are like this, very simple way: UserEntity.java @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Size(max = 50) @Column(name = "username", length = 50) private String username; @ManyToMany @Cache(usage =

Rather than child is deleting its updating ,when parent is deleted

情到浓时终转凉″ 提交于 2019-12-13 04:09:50
问题 My problem is when i delete the parent, child is not deleted but instead of deleting child ,child is updating.Parent table is Employee and child table is EmployeeProject there is one-to-many relation ship exist between employee and project one employee had many projects what i have done please check where i m mistaking this is the query is showing on console Hibernate: update employee_project set employeeNumber=null where employeeNumber=? Hibernate: delete from employee where EMPLOYEE_NUMBER=

Unable to generate tables using hibernate

 ̄綄美尐妖づ 提交于 2019-12-13 04:04:07
问题 I am trying to generate some tables using hibernate. I have following classes : class Candidate { long candidateID; String candidate_name; List<Project> projects; } class Project { long projectID; Set<String> technologies; } and I want to generate tables like below : +------------------------------+ candidates ------------------------------| candidate_id | candidate_name +------------------------------+ +------------------------------+ projects ------------------------------| candidate_id |

How can one override a method from a Hibernate @MappedSuperclass but keep the originial mapping?

狂风中的少年 提交于 2019-12-13 04:03:21
问题 I have a mapped super class that I use to define a method it's persistence mapping. I am using the table-per-class inheritance strategy. For example here is some simple class inheritance: @MappedSuperclass public class Feline { private Long id; private String identifier; @GeneratedValue(strategy = "GenerationType.AUTO") @Id public Long getId() { return id; } public String getIdentifier() { return identifier; } // other getters and setters, methods, etc. } The next class does not override the

Is it possible to map different field types using hibernate?

我是研究僧i 提交于 2019-12-13 02:59:26
问题 I'm wondering if it's possible to map different data types. For instance, I have a Visit data type in Java, which has a userEmail field which is of the type String, and can I map it with hibernate to a database table which would have userID instead of userEmail? And according to the id it would find the email and return to java the email and vice versa? Is this possible? If yes, then how would the mapping look like? Or how is this supposed to look like: <many-to-one name="patientEmail" column

Wrong HBM mappings when using a mapped superclass in an inheritance graph for ColdFusion 9.0.1 Hotfix 2

不羁的心 提交于 2019-12-12 17:28:11
问题 Let's say I have an inheritance graph where the base class extends a mapped superclass: component name="Entity" mappedSuperClass="true" { property name="CreatedOn"; } component name="Pet" extends="Entity" table="Pet" discriminatorcolumn="pet_type" { property name="PetId" fieldtype="id" generator="native"; property name="Name"; } component name="Dog" extends="Pet" table="Pet" discriminatorvalue="Dog" { property name="FavoriteFood"; } component name="Cat" extends="Pet" table="Pet"

Hibernate/JPA: storing constants in entity class?

↘锁芯ラ 提交于 2019-12-12 14:27:31
问题 I work on remote project and found interesting record in log: 2015-12-26 00:28:30,835 DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate Caller+0 at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:251) => alter table bail add column monthName tinyblob with logging set to: <logger level="trace" name="org.hibernate.tool.hbm2ddl"/> when try to identify what happen to: <prop key="hibernate.hbm2ddl.auto">update</prop> on first run from backup. When I have seen Bail.java source I am

hibernate entity is not mapped since version 4.3.2

社会主义新天地 提交于 2019-12-12 13:51:47
问题 With the change hibernate (hibernate-entitymanager) version 4.3.1.Final to 4.3.2.Final my HQL-Statements do not work anymore. I made a working example with hibernate-entitymanager 4.3.1.Final. And tested with hibernate-entitymanager version higher then 4.3.1.Final and it fails. Here is my test: pom snippet: <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>4.3.1.Final</version> </dependency> persistence.xml snippet: <persistence-unit name=