hibernate-mapping

Hibernate many-to-many data retrieval

帅比萌擦擦* 提交于 2019-12-25 01:47:16
问题 I have two objects User and Contact, with many to many relation, and I am using an intermediate table for this relation USER_CONTACT Saving the data in this association is fine, but the retrieval is an issue. I need to retrieve the data based on the User, but what I am getting is all the Contacts, for all the Users. It will be good if you can let me know what wrong I am doing. public class User { private Integer userID; private String userLoginEmail; private String password; private Set

read and write blobs by mapping them to binary data

心不动则不痛 提交于 2019-12-25 01:35:20
问题 I'm getting the following exception trying to read a blob from a Sybase DB using hibernate JPA. Entity @Lob @Column(length=100000) private byte[] fileContent; public byte[] getFileContent() { return fileContent; } public void setFileContent(byte[] fileContent) { this.fileContent = fileContent; } ioc.Registry The method com.sybase.jdbc3.jdbc.SybResultSet.getBlob(String) is not supported and should not be called. ioc.Registry Operations trace: ioc.Registry [ 1] Triggering event 'activate' on

Correct cast in ResultTransformer

无人久伴 提交于 2019-12-24 19:06:08
问题 I am using Hibernate result transformer for fetching list of results from the database as follows: Query query = em.createNativeQuery("SELECT 1 as myTrueBoolean, 2 as myInt") query.unwrap(org.hibernate.Query.class).setResultTransformer‌​(Transformers.aliasT‌​oBean(myDataClass)); query.fetchResultList() Than I could define a data class as follows: class MyDataClass { boolean myTrueBoolean; int myInt; } The problem is that the transformer will not cast correctly the data as it will assign

Spring JPA/ Hibernate : How to map polymorphic relation on non primary columns

你说的曾经没有我的故事 提交于 2019-12-24 18:32:08
问题 class B{ @Any(metaColumn = @Column(name = "ITEM_TYPE")) @AnyMetaDef(idType = "long", metaType = "string", metaValues = { @MetaValue(targetEntity = A.class, value = "A") }) @Cascade( { org.hibernate.annotations.CascadeType.ALL}) @JoinColumn(name = "ITEM_ID") private A a; ... ... } I'm trying to Join table A and table B where B.item_type ='A' is constant and B.item_id= A.id . It is throwing me Caused by: org.hibernate.MappingException: Foreign key (FKi1uuph2wrvxtx66s7n7i1s09a:B [item_type,item

get updated row in one to many mapping using hibernate

可紊 提交于 2019-12-24 16:53:21
问题 I have two entities Issue and Issue_Tracker . I have joined both table in an one to many mapping. In Issue_Tracker , We can have multiple entries like issue_id tracker_status tracked_time 123 Assigned 1/8/2013 11:44 123 Assigned 1/8/2013 11:45 123 Completed 1/8/2013 11:52 32 Assigned 1/9/2013 16:46 33 Assigned 1/9/2013 16:47 33 Cancel 1/9/2013 16:49 I want to Order the Issue_tracker entity by tracked_time so I can get only last update tracker_status .I am using criteria to get data,However I

get updated row in one to many mapping using hibernate

旧街凉风 提交于 2019-12-24 16:53:09
问题 I have two entities Issue and Issue_Tracker . I have joined both table in an one to many mapping. In Issue_Tracker , We can have multiple entries like issue_id tracker_status tracked_time 123 Assigned 1/8/2013 11:44 123 Assigned 1/8/2013 11:45 123 Completed 1/8/2013 11:52 32 Assigned 1/9/2013 16:46 33 Assigned 1/9/2013 16:47 33 Cancel 1/9/2013 16:49 I want to Order the Issue_tracker entity by tracked_time so I can get only last update tracker_status .I am using criteria to get data,However I

unidirectional many to one relationship with inheritance

萝らか妹 提交于 2019-12-24 15:38:33
问题 I am trying to map a many to one relationship between class ED and class TEL in hibernate, but I am getting the following error when I try to Run As.. Run on server in eclipse: Caused by: org.hibernate.MappingException: Could not determine type for: my.package.name.TEL, at table: ed, for columns: [org.hibernate.mapping.Column(reference)] How can I resolve this error? The ED class only has one TEL property, but the TEL class is used as properties in so many other classes that it does not make

hql inner join Path expected for join! error

懵懂的女人 提交于 2019-12-24 12:12:44
问题 hi have following entities; @Entity public class FilesInfo { @Id @GeneratedValue private Integer id; private String name; private String url; @OneToMany(cascade= CascadeType.ALL) @JoinColumn(name="fileId") private Collection<FilesShare> filesShared = new ArrayList<FilesShare>(); public Collection<FilesShare> getFilesShared() { return filesShared; } public void setFilesShared(Collection<FilesShare> filesShared) { this.filesShared = filesShared; } //getters & setters } the other one @Entity

detached entity passed to persist: entities.Event

大兔子大兔子 提交于 2019-12-24 08:29:25
问题 I am having an issue with a hibernate mapper while trying to store items within the database I am trying to persist a Booking object I am trying to store an element with a many to one relationship with an element that already has a many to one relationship with another Booking class has a many to one relationship with the Event class but the Event Class already has a many to one relationship with the Users Class Which I am also trying to save again within the same table Booking{ //many to one

Hibernate: Best way to configure 3-way many to many relationship

為{幸葍}努か 提交于 2019-12-24 05:27:06
问题 I am trying to figure out the best way to map a three way @ManyToMany relationship in Hibernate. The following is my data model: As you can see the TeamPosition table is nothing more than 3 foreign keys. Hibernate provides helpful functionality in the form of a ManyToMany mapping between two tables and a mapping table that joins them where a third Hibernate entity does not need to be created. Of course if that mapping table had additional data like "StartDate', 'EndDate' for example then the