hibernate-mapping

org.hibernate.exception.SQLGrammarException: could not insert [com.sample.Person]

微笑、不失礼 提交于 2019-12-03 08:34:58
I'm trying to set up a small working sample of Hibernate that I found here However when I run the code I get the follwing error Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.sample.Person] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java

Avoid Circular Dependency

你离开我真会死。 提交于 2019-12-03 07:42:34
I am developing a travel management application. The design in question is something like following : Each person in a tour is designated as a Traveler. Each Traveler has a Passport. Now, a Traveler can be a MainMember or a SubMember, depending on whether or not he is the head of the family. A MainMember decides stuff like TourPackage, total amount for his travelling family, etc. A SubMember is dependent on the MainMember while travelling. So, if a MainMember is deleted, all its SubMembers have to be deleted as well. So, A Traveler has a Passport. (One to One relationship) A Traveler is either

Spring and/or Hibernate: Saving many-to-many relations from one side after form submission

末鹿安然 提交于 2019-12-03 07:07:42
问题 The context I have a simple association between two entities - Category and Email (NtoM). I'm trying to create web interface for browsing and managing them. I have a simple e-mail subscription edit form with list of checkboxes that represents categories, to which given e-mail belongs (I registered property editor for Set<Category> type). The problem Form displaying works well, including marking currently assigned categories (for existing e-mails). But no changes are saved to EmailsCategories

Hibernate persist Map<String, String> without referencing another tables

时光怂恿深爱的人放手 提交于 2019-12-03 06:49:56
Could you please help me to persist map of strings with Hibernate? Map values come from client and are random, so I don't want to store separate table for map's values Exception Caused by: org.hibernate.AnnotationException: Associated class not found: java.lang.String Code @Entity public class UserConfig { @Id @SequenceGenerator(sequenceName = "CONFIG_SEQ", name = "ConfigSeq", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ConfigSeq") private Long id; @ElementCollection(targetClass = String.class) @CollectionTable(name = "MAP") @MapKey(name="key") @Column

How to add data of different records to a single record?

放肆的年华 提交于 2019-12-03 06:49:32
If do not have time please have a look at the example I have two types of users, temporary users and permanent users. Temporary users use the system as guest just provide their name and use it but system needs to track them. Permanent users are those that are registered and permanent. Once user create a permanent record for himself, I need to copy all the information that has been tracked while user was a guest to his permanent record. Classes are as following, @Entity public class PermUser{ @Id @GeneratedValue private long id; @OneToMany private List Favorites favorites; .... } @Entity public

How to avoid creating a new row if similar row exists?

梦想的初衷 提交于 2019-12-03 02:26:53
I need to configure hibernate to avoid creating duplicate rows, (although the row exists it creates a new one, and since only one filed is set it set all the rest to NULL) Lets say I have a row as following id des index age 1 MyName 2 23 Although I just set MyName as des and it already exists in the Name table hibernate create a new row as following id des index age 1 MyName 2 23 2 MyName Null Null << new row with null values will be created rather than updating the previous one When I want to sa . So I have added the following annotation to my class but it crossed the Entity, and

Hibernate CriteriaBuilder to join multiple tables

大城市里の小女人 提交于 2019-12-03 02:06:22
I'm trying to join 4 tables using hibernate criteriabuilder.. Below are the tables respectively.. ` @Entity public class BuildDetails { @Id private long id; @Column private String buildNumber; @Column private String buildDuration; @Column private String projectName; } @Entity public class CodeQualityDetails{ @Id private long id; @Column private String codeHealth; @ManyToOne private BuildDetails build; //columnName=buildNum } @Entity public class DeploymentDetails{ @Id private Long id; @Column private String deployedEnv; @ManyToOne private BuildDetails build; //columnName=buildNum } @Entity

Receiving the org.hibernate.TypeMismatchException Exception [closed]

坚强是说给别人听的谎言 提交于 2019-12-03 01:21:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm working on an application with Spring using SpringMVC, i'm encountering the following error and i don't know how to deal with it . now i have this message in Console : org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Integer, got class java.lang.String at org

Unique Constraint Over Multiple Columns

前提是你 提交于 2019-12-02 21:43:14
I am using SEAM 2/Hibernate along with PostgreSQL 9 database. I have the following table Active Band =========== active_band_id serial active_band_user text active_band_date timestamp active_band_process integer I would like to add a constraint that ensures each new entry has a unique combination of active_band_user and active_band_date. There could potentially be many attempted inserts per second so I need this to be as efficient as possible, is there a SEAM / hibernate annotation I can use in the entity mapping? Thanks in advance There is no Hibernate annotation that checks uniqueness before

Delete JSF Datatable row(columns in row from different database)

纵饮孤独 提交于 2019-12-02 20:52:45
问题 I have a JSF datatable, it has three columns, those are:Work_Type_Desc, Project_Phase, and Activity_Desc. Those columns comes from 2 different database tables, the relationship of those two tables are one-to-many. The 1st Table name is Work_Type. It has 1) Work_Type_Cd, 2)Work_Type_Desc, 3)Created_By_Name, 4)Created_DT, 5)Updated_By_Name, 6) Updated_DT The 2nd Table name is Activity_Type. It has 1)Activity_Cd,2) Work_Type_Cd,3)Project_Phase,4)Activity_Desc, 5)Created_By_Name, 6)Created_DT, 7