hibernate-mapping

To map a database view with no primary key, in hibernate xml mapping

女生的网名这么多〃 提交于 2019-11-30 20:22:48
I have created a view which will be used for fetching the data only(readonly) View : Grid_View > My Hibernate hbm file <hibernate-mapping> <class name="hibernate.domain.View" table="Grid_View" mutable="false"> <property name="ACCT_BR_CD" type="string"> <column name="ACCT_BR_CD"/> </property> <property name="ACCT_NO" type="string"> <column name="ACCT_NO"/> </property> <property name="LGL_ENTY_NM" type="string"> <column name="LGL_ENTY_NM"/> </property> <property name="CUST_CTRY_CD" type="string"> <column name="CUST_CTRY_CD"/> </property> <property name="ACCT_SRC_SYS_CD" type="string"> <column

HIbernate Mapping Exception: PropertyNotFoundException: Could not find a setter

大兔子大兔子 提交于 2019-11-30 19:26:35
I have two POJO's ,STOCK and STOCK_DETAILS (one to many relationship). Also I have one interface IAUDITLOG (having two methods). I need to implement this interface with BOTH POJO's and want to write some implementation within those methods. But when I implement IAUDITLOG interface with child class "STOCKDETAILS" then it gives exception "that you should have setter property" STOCK CLASS: @Entity @Table(name = "stock") public class Stock implements java.io.Serializable, IAuditLog { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private

java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()

拈花ヽ惹草 提交于 2019-11-30 17:01:40
问题 I have a maven project that uses spring, hibernate (3.6.4), GWT(2.3), drools,.... Everything used to work fine till I began using hibernate OneToMany, ManyToMany relations... When I run the app from "mvn jetty:run", it works, but When I run the app from gwt embedded jetty and from a jetty version that I have embedded in my app, I get: [INFO] Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z [INFO] at org.hibernate.cfg.AnnotationBinder

Hibernate Many-to-many association: left hand side collection contains elements, but right hand side collection is empty

▼魔方 西西 提交于 2019-11-30 15:13:39
问题 I got a problem with a many to many association in my persistence layer. My scenario is the following: A user can has several roles and a role can have several user attached to it. During the tests I encountered a strange behavior. I created role object and several user objects. The role was set to each of the users. After this the users were saved using a DAO. Then one of the user gets loaded to check whether he got the role that was passed to him before saving the user object. Calling

remove collection with delete-orphan not work with null assignment? :(

点点圈 提交于 2019-11-30 14:41:10
I am having problems removing another entity through cascade delete-orphan. It works when I clear the associated set collection, but not when I make the set collection null. Let me explain in detail. The config snippet: <class name="com.sample.CategoriesDefault" table="cats"> <id name="id" column="id" type="string" length="40" access="property"> <generator class="assigned" /> </id> <version name="version" column="objVrs" unsaved-value="negative"/> <set name="bla" lazy="false" cascade="all-delete-orphan" inverse="true"> <key column="idCats" not-null="true"/> <one-to-many class="com.sample.BLA"/

Hibernate lazy loading for reverse one to one workaround - how does this work?

本小妞迷上赌 提交于 2019-11-30 14:09:32
问题 I was having problems today with lazy loading not working when using a mapped by collection. I found this excellent article that seems to fix the problem http://justonjava.blogspot.co.uk/2010/09/lazy-one-to-one-and-one-to-many.html One thing I do not understand is how the workaround using FieldHandled works. Can anyone help me understand this? The code in question is below (copied from the example on the link): @Entity public class Animal implements FieldHandled { private Person owner;

@ManyToOne and @BatchSize

≯℡__Kan透↙ 提交于 2019-11-30 14:03:24
I found in some old code strange thing (at least for me). The field which is annotated @ManyToOne is also annotated with @BatchSize . I always thought that @BatchSize annotation only affects when annotated at class level or on a collection ( @OneToMany ) and affects pre-fetching when iterating. But maybe I am wrong and annotating @ManyToOne with @BatchSize affects something. I can't find the answer in the documentation. Does annotating @ManyToOne with @BatchSize have sense? @ManyToOne associated with @BatchSize could make sense only if the corresponding field is marked as lazy ( lazy=true ).

How to load only ids from Many to Many mapping tables?

自古美人都是妖i 提交于 2019-11-30 14:01:40
问题 In a Many to Many relation between two table with a Mapping table in between, how can I only load ids for the second entity. Following is the example to explain what I want to achieve here. Below is a sample schema create table user( id int PrimaryKey, name text ) create table pages ( id int PrimaryKey, page_name text ) create table user_page ( id_user int, id_page int, PrimaryKey (id_user, id_page) ) Note: there are additional columns in user and page tables which i have not included here

Hibernate Many-to-many association: left hand side collection contains elements, but right hand side collection is empty

纵然是瞬间 提交于 2019-11-30 13:55:42
I got a problem with a many to many association in my persistence layer. My scenario is the following: A user can has several roles and a role can have several user attached to it. During the tests I encountered a strange behavior. I created role object and several user objects. The role was set to each of the users. After this the users were saved using a DAO. Then one of the user gets loaded to check whether he got the role that was passed to him before saving the user object. Calling getRoles() on the user shows that the role was set correctly. To check whether the inverse direction also

Map entity using query in Hibernate

不羁岁月 提交于 2019-11-30 12:56:25
问题 consider table sales (id, seller_id, amount, date) and here is a view that is generated from sales using query SELECT seller_id, SUM(amount) FROM sales GROUP BY seller_id total_sales (seller_id, amount) I want to make an entity for total sales but without the view on the sql side. This entity will be constructed from a query. The closest thing I found is this , but I could not make it work. Even if I define the loader, hibernate looks for the entity's table and gives an error if it cannot