hibernate-mapping

composite key join columns

╄→гoц情女王★ 提交于 2019-12-08 06:58:45
问题 My table VENDORBRANCH has composite keys : "vendorCode" and "vendorBranchCode" which I have defined using the @Id annotation and using @IdClass. The field "vendorCode" is referenced as a foreign key in VENDORCRTERMS class. I'm using postgresql db. Right now my sql query in the service implimentation looks like this but i want to include composite keys in the query: Query<?> query = session.createQuery("from VENDORBRANCH where vendorCode = ?"); query.setParameter(0, mf01_vendorCode); I'm very

Hibernate entities mapping: Retrieve VARCHAR as boolean

别说谁变了你拦得住时间么 提交于 2019-12-08 06:56:43
问题 I have a table INCIDENCIA in my database that has a VARCHAR column VISIBLE with two possible values: Y or N matching true or false . I have it mapped in this entity: @Entity public class Incidencia { private String visible; //other fields @Basic @Column(name = "VISIBLE") public String getVisible() { return visible; } public void setVisible(String visible) { this.visible = visible; } } This field is a String since column in database is a VARCHAR, however I would like to retrieve it as java

Hibernate entities mapping: Retrieve VARCHAR as boolean

ぐ巨炮叔叔 提交于 2019-12-08 06:47:30
I have a table INCIDENCIA in my database that has a VARCHAR column VISIBLE with two possible values: Y or N matching true or false . I have it mapped in this entity: @Entity public class Incidencia { private String visible; //other fields @Basic @Column(name = "VISIBLE") public String getVisible() { return visible; } public void setVisible(String visible) { this.visible = visible; } } This field is a String since column in database is a VARCHAR, however I would like to retrieve it as java.lang.Boolean with a Y/N deserialization. Is there any way to do this by Hibernate annotations? Thanks. You

Hibernate Creating Unwanted Mapping Tables

ぐ巨炮叔叔 提交于 2019-12-08 05:44:28
问题 I am creating a schema. My schema is as follows @Entity @Table(name = "PROMOTION") public class Promotion { @Id @Column (name = "promotion_id") private String promotionId; @JoinColumn(name = "seller_id") private List<Seller> sellerList; }; @Entity @Table(name = "SELLER") public class Seller { @Id @Column (name = "seller_id") private String sellerId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "promotion_id") private Promotion promotion; @ManyToMany(fetch = FetchType.LAZY)

NHibernate composite id mapping issue, bi/uni-directional OneToMany, ManyToOne and ManyToMany

谁说胖子不能爱 提交于 2019-12-08 05:13:55
问题 In my project all of entities have composite primary keys [systemId as long, deviceId as long, id as long]. Values filled manualy before I save the entity. I'm using "code first" approach and to provide simplicity references NHibernate.Mapping.Attributes extension to define schema with attributes just like in Java based Hibernate. All entities have an abstract base type which provides shared properties and functionality: [Serializable] public abstract class EntityBase { [CompositeId(0, Name =

Hibernate EmptyInterceptor onFlushDirty() is not executing

北战南征 提交于 2019-12-08 02:05:14
问题 I want to do Audit for my entity updates. So I have implemented EmptyInterceptor . My onFlushDirty() method is not executing, but afterTransactionCompletion() does executes I'm using Spring 4.1 and Hibernate 5.0 + I have not done any configuration rather than @Component in configuration file till afterTransactionCompletion() get executed. What I'm missing here ? Also how to intercept Event query.executeUpdate() ? My Interceptor class is as follows: @Component public class AuditLogInterceptor

JavaFX BooleanProperty and Hibernate

别等时光非礼了梦想. 提交于 2019-12-08 02:04:26
问题 I'm trying to add JavaFX BooleanPropety to my model which is persisted by Hibernate but I'm getting the following error. Caused by: org.hibernate.MappingException: Could not determine type for: javafx.beans.property.BooleanProperty. JavaFX StringProperty persisting just fine so I'm confused a little bit. My model class is the following @Entity public class Currency { private String uuid; private BooleanProperty isDefault = new SimpleBooleanProperty(); private StringProperty name = new

HQL: get last element of collection

纵饮孤独 提交于 2019-12-08 01:14:44
问题 I have Person entity, which have many-to-many relationship with Address entity (which has some boolean property). This relationship represent with help of separate table (which is not an entity) I need a query like: "from Person p where p.addresses is empty or p.addresses.getLastElement.propert is TRUE" Question: Can I pull the last element of p.addresses collection in HQL question? If yes, How? If no, can I represent many-to-many relationship as entity? 回答1: Can I pull the last element of p

How to use Oracle query hint in Hibernate

无人久伴 提交于 2019-12-07 16:28:52
问题 I am trying to use Oracle hint in Hibernate to call force index, but didn't find any proper API in Hibernate 3.6.10.Final. I somehow tried with projections in Hibernate criteria: proList.add(Projections.sqlProjection("/*+ INDEX_DESC(CONTACT_USER_FK_I) */", new String[]{}, new Type[]{})); proList.add(Projections.property("objectId")); criteria.setProjection(proList); return criteria.list(); But I am getting the exception below: EXCEPTION Caused by: 8 SQL Error (could not execute query; SQL

Add mapping classes as a separate xml file in hibernate

无人久伴 提交于 2019-12-07 08:04:10
问题 How can i add my hibernate mapping classes into cfg file as a separate xml file. Here is my hibernate configuration file . <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/test <property name="connection.username">root</property> <property name="connection.password">rot@pspl#12</property> <!-- JDBC connection pool (use the built