hibernate-annotations

Can an INITIALLY DEFERRED constraint be defined using a Hibernate annotation?

旧时模样 提交于 2019-12-02 07:13:11
I have a table with a column that has a UNIQUE constraint. I want the constraint checking to be deferred to commit time. If I create it using Postgres SQL like this (many columns omitted): CREATE TABLE instrument ( id bigint NOT NULL, name character varying(255) NOT NULL, CONSTRAINT instrument_pkey PRIMARY KEY (id), CONSTRAINT instrument_name_key UNIQUE (name) DEFERRABLE INITIALLY DEFERRED ) Then everything works as expected. If I define it to Hibernate like this: import java.io.Serializable; import javax.persistence.*; import org.hibernate.annotations.ForeignKey; @Entity @Table(name=

nvarchar in sql ,oracle and mysql in Hibernate annotation mapping

时光毁灭记忆、已成空白 提交于 2019-12-02 04:25:31
We are using MS-SQL ,Oracle and mysql as our database. We have used hibernate annotations to create tables, in the annotation class file we have declared column definition as @Column(name="UCAALSNO",nullable=false,columnDefinition="nvarchar(20)") and this works fine for MS-SQL. But when it comes to Oracle nvarchar throws an exception as oracle supports only nvarchar2 and Mysql only supports nchar()(max length=255) How to create annotation file to support datatype nvarchar for three databases. 来源: https://stackoverflow.com/questions/23774474/nvarchar-in-sql-oracle-and-mysql-in-hibernate

Java Hibernate Mapping Exception! (Could not determine type for: java.util.Map)

人盡茶涼 提交于 2019-12-01 17:28:55
I have made a class with name of Movie with folowing fields: @Id @GeneratedValue private Long id; private String name; @ElementCollection(targetClass = String.class) private Map<String, String> properties; private Double rate; private Integer votersCount; private Date releaseDate; private Integer runtime; @ManyToMany @JoinTable(name = "movie_director") @IndexColumn(name = "directorIndex") private List<Person> directors; @ManyToMany @JoinTable(name = "movie_writer") @IndexColumn(name = "writerIndex") private List<Person> writers; @OneToMany @IndexColumn(name = "roleIndex") private List

hibernate: ternary association mapping

让人想犯罪 __ 提交于 2019-12-01 12:30:40
Technology Description: Hibernate annotation- 3.4.0.GA java 1.5 table : users_roles_branches columns : user_id, role_id, branch_id A user is assigned different roles for different branches of a company. Now i have one java pojo class public class branch { @ManyToMany @JoinTable(name = "users_roles_branches", joinColumns = { @JoinColumn(name="branch_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") }) @MapKeyManyToMany(joinColumns = { @JoinColumn(name = "user_id", unique = false) }) public Map<User, Role> getUserRoleMap() { return userRoleMap; } } Basic requirement is to retrieve

hibernate: ternary association mapping

纵然是瞬间 提交于 2019-12-01 09:52:02
问题 Technology Description: Hibernate annotation- 3.4.0.GA java 1.5 table : users_roles_branches columns : user_id, role_id, branch_id A user is assigned different roles for different branches of a company. Now i have one java pojo class public class branch { @ManyToMany @JoinTable(name = "users_roles_branches", joinColumns = { @JoinColumn(name="branch_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") }) @MapKeyManyToMany(joinColumns = { @JoinColumn(name = "user_id", unique = false) })

a different object with the same identifier value was already associated with the session error on save [duplicate]

♀尐吖头ヾ 提交于 2019-12-01 04:30:25
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Spring + Hibernate : a different object with the same identifier value was already associated with the session I've been having problems with my hibernate annotations. I have a bidirectional relationship between 2 classes. Here's the mapping(thanks to axtavt): @Entity public class Receipt implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @OneToMany(cascade = CascadeType

java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

最后都变了- 提交于 2019-11-30 20:26:52
I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using tomcat 6 and postgresql 9.1 my servletdispacher.xml ` <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.postgresql.Driver" /> <property name="url" value="jdbc:postgresql://localhost:5432/car" /> <property name="username" value="postgres" /> <property name=

Hibernate buildSessionFactory() Exception

▼魔方 西西 提交于 2019-11-30 20:09:18
I have a serious problem with hibernate. I followed various books und online tutorials, but I ever get the same Exception "ExceptionInInitializerError" obviously thrown by the HibernateUtil.java Line SessionFactory sf = cfg.configure().buildSessionFactory(); My Tomcat log says the following: Caused by: java.lang.ExceptionInInitializerError at de.marcelstuht.nerven2.server.HibernateUtil.buildSessionFactory(HibernateUtil.java:23) at de.marcelstuht.nerven2.server.HibernateUtil.<clinit>(HibernateUtil.java:8) at de.marcelstuht.nerven2.shared.model.Account.<init>(Account.java:52) at de.marcelstuht

java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

不羁的心 提交于 2019-11-30 17:00:08
问题 I'm trying to configure org.apache.commons.dbcp.BasicDataSource as bean in web.xml under a tomcat project using tomcat 6 and postgresql 9.1 my servletdispacher.xml ` <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.postgresql.Driver" /> <property name="url" value=

@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 ).