[Hibernate-JIRA] Created: (HHH-5042) TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range
by Guenther Demetz (JIRA)
TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range
-----------------------------------------------------------------------------------------------------------------------
Key: HHH-5042
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5042
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1
Environment: Hibernate: 3.5 , db: HSQLDB (not relevant)
Reporter: Guenther Demetz
Priority: Critical
Attachments: TestTableGenerator.java
This bug is new in 3.5
In version 3.5 class MultipleHiLoPerTableGenerator.java was modified introducing a
new increment variable
IntegralDataTypeHolder value;
along with
int lo;
The problem in the new code is that only value get's incremented whilst variable lo
is still used to check when a new hiVal must be obtained.
if ( lo > maxLo ) {
IntegralDataTypeHolder hiVal = (IntegralDataTypeHolder) doWorkInNewTransaction( session );
as lo is never incremented, MultipleHiLoPerTableGenerator continues to deliver numbers without ever update
hibernate_sequences.next_hi_value on the database (only one unique update is propagates at the first insert)
This lead to duplicate keys as soon another session from another sessionfactory tries to insert new objects on the concerning table.
Please see attached testcase.
IMPORTANT ADVICE TO RUN THE TESTCASE:
as the testcase uses 2 sessionfactories hibernate.hbm2ddl.auto=create cannot be used!!
Schema has to be exported separately and the testcase must run without hbm2ddl.auto property!
Here the schema for HSQLDB:
create table A (oid bigint not null, name varchar(255), version integer not null, primary key (oid), unique (name))
create table hibernate_sequences ( sequence_name varchar(255), sequence_next_hi_value integer )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-4991) ManyToMany table not joined due to max_join_depth parameter, results to SQL exceptions
by Sergii Novotarskyi (JIRA)
ManyToMany table not joined due to max_join_depth parameter, results to SQL exceptions
--------------------------------------------------------------------------------------
Key: HHH-4991
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4991
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR-2, MacOS X, MySQL 5.1
Reporter: Sergii Novotarskyi
Attachments: Example.zip
*max_join_depth* parameter prevents Hibernate from joining one end of ManyToMany relationship when using Criteria API, if the relationship is "far" enough from the root entity.
{quote}
Criteria c = session.createCriteria(SubEntity.class)
.createAlias("entity", "e") // ManyToOne, inner join
.createAlias("e.entity", "ee") // ManyToOne, inner join
.createAlias("ee.sides", "s") // ManyToMany, inner join + left outer join
.setProjection(Projections.count("id"))
.add(Restrictions.ne("s.data", "abc"));
{quote}
When *max_join_depth* is set to *2* (default) the above example generates following SQL query
{quote}
select count(this_.sub_id) as y0_ from SubEntity this_
inner join SubMainEntity e1_ on this_.submain_id=e1_.submain_id
inner join MainEntity ee2_ on e1_.main_id=ee2_.main_id
inner join MainSide sides7_ on ee2_.main_id=sides7_.main_id
where s3_.data<>?
{quote}
The query, naturally, throws the "Unknown column 's3_.data' in 'where clause'" exception.
Expected query would be
{quote}
select count(this_.sub_id) as y0_ from SubEntity this_
inner join SubMainEntity e1_ on this_.submain_id=e1_.submain_id
inner join MainEntity ee2_ on e1_.main_id=ee2_.main_id
inner join MainSide sides7_ on ee2_.main_id=sides7_.main_id
left outer join SideEntity s3_ on sides7_.side_id=s3_.side_id
where s3_.data<>?
{quote}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-5125) The annotations @Entity and @MappedSuperclass used in one class produce a nullpointerexception
by Simone Rodenbach (JIRA)
The annotations @Entity and @MappedSuperclass used in one class produce a nullpointerexception
----------------------------------------------------------------------------------------------
Key: HHH-5125
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5125
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 3.5.1
Environment: MS SQL Server
Reporter: Simone Rodenbach
Priority: Critical
Caused by: java.lang.NullPointerException
at org.hibernate.cfg.ClassPropertyHolder.addPropertyToMappedSuperclass(ClassPropertyHolder.java:133)
at org.hibernate.cfg.ClassPropertyHolder.addPropertyToPersistentClass(ClassPropertyHolder.java:118)
at org.hibernate.cfg.ClassPropertyHolder.addProperty(ClassPropertyHolder.java:98)
at org.hibernate.cfg.ClassPropertyHolder.addProperty(ClassPropertyHolder.java:81)
at org.hibernate.cfg.annotations.PropertyBinder.bind(PropertyBinder.java:246)
at org.hibernate.cfg.annotations.PropertyBinder.makePropertyValueAndBind(PropertyBinder.java:200)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1979)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:762)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:726)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:636)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:359)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (ANN-756) @Column annotation ignored when placed on entity's @Id property
by sagi mann (JIRA)
@Column annotation ignored when placed on entity's @Id property
---------------------------------------------------------------
Key: ANN-756
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-756
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.1.GA
Environment: hib core 3.2.6, my sql 5
Reporter: sagi mann
Hibernate docs specify that when using a compound key class, a Hibernate optional feature is to place @Column annotations within the key class. The observed behavior is that Hibernate ignores @Column if placed ANYWHERE ELSE, for example, on the entity's ID properties. In other words, the standard JPA way of annotating ID fields is not working under Hibernate, and the "optional" feature is mandatory.
Example how to reproduce (see comments inside the code regarding the inconsistency above). Accessors were omitted for clarity:
// the identity class
@Entity
public class SecurityIdentity implements Serializable {
public SecurityIdentity() {}
@Id
@Column(name="IDENTITY_ID")
@GeneratedValue
public Long getId() ...
@Column(name="IDENTITY_NAME")
public String getName() ...
@Override public boolean equals(Object o) ...
@Override public int hashCode() ...
}
// the domain class
@Entity
public class SecurityDomain implements Serializable {
public SecurityDomain() {}
@Id
@Column(name="DOMAIN_ID")
@GeneratedValue
public Long getId() ...
@Column(name="DOMAIN_NAME")
public String getName() ...
@Override public boolean equals(Object o) ...
@Override public int hashCode() ...
}
// the domain-identity mapping class
@Entity
@IdClass(pu1.DomainIdentityPK.class)
public class DomainIdentity implements Serializable {
public DomainIdentity() {}
@Id
public Long getDomainId() ...
@Id
public String getUserAlias() ...
@ManyToOne
@JoinColumn(name="IDENTITY_ID")
public SecurityIdentity getSecurityIdentity() ...
@ManyToOne
@JoinColumn(name="DOMAIN_ID", insertable=false, updatable=false)
public SecurityDomain getSecurityDomain() { return securityDomain; }
public void setSecurityDomain(SecurityDomain securityDomain) {
this.securityDomain = securityDomain;
this.domainId = (securityDomain != null ? securityDomain.getId() : null);
}
private SecurityDomain securityDomain;
}
// the map key class
public class DomainIdentityPK implements Serializable {
public DomainIdentityPK() {
}
/********* @Column inconsistency - cannot be placed inside the entity - only inside the PK class *******/
@Column(name="DOMAIN_ID")
public Long getDomainId() ...
[b]@Column(name="ALIAS")[/b]
public String getUserAlias() ...
public boolean equals(Object o) ...
public int hashCode() ...
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-2608) allow delete-orphan cascade style in one-to-one mapping
by Joe Kelly (JIRA)
allow delete-orphan cascade style in one-to-one mapping
-------------------------------------------------------
Key: HHH-2608
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2608
Project: Hibernate3
Issue Type: New Feature
Components: core
Affects Versions: 3.2.4
Environment: 3.2.4, DB2 v8
Reporter: Joe Kelly
Please allow the cascade-style "delete-orphan" for one-to-one relationships. When I try to use that cascade style, I get the exception "org.hibernate.MappingException: single-valued associations do not support orphan delete".
I realize that the reference manual says "Note that single valued associations (many-to-one and one-to-one associations) do not support orphan delete." But why? I can think of many cases where you WOULD want parent-child semantics in a one-to-one relationship.
For example, I have encountered some legacy databases where an entity has all of its fields stored in one table EXCEPT for an optional large field (e.g. a blob field) that is stored in another table, presumably for some performance or storage optimization reason. In this case the two tables are joined with a one-to-one relationship, using a shared primary key. Here are some hypothetical tables, classes and mappings that illustrate this example:
company
(
company_id (PK)
name
)
company_extra
(
company_extra_id (PK), (FK referencing company.company_id)
some_extra_info
)
class Company
{
int companyId;
String name;
CompanyExtra companyExtra;
}
class CompanyExtra
{
int companyExtraId;
String someExtraInfo;
Company company;
}
<class name="Company" table="company">
<id name="companyId" column="company_id">
<generator class="sequence">
<param name="sequence">COMPANY_SEQ</param>
</generator>
</id>
<property name="name" column="name" />
<one-to-one name="companyExtra" class="CompanyExtra" cascade="all, delete-orphan" />
</class>
<class name="CompanyExtra" table="company_extra">
<id name="companyExtraId" column="company_extra_id" unsaved-value="null">
<generator class="foreign">
<param name="property">company</param>
</generator>
</id>
<property name="someExtraInfo" column="some_extra_info" />
<one-to-one name="company" class="Company" constrained="true" />
</class>
For the purposes of this example, CompanyExtra is a child of Company and belongs to one and only one instance of Company. It cannot be shared between Company instances and it cannot be an orphan (i.e. it cannot exist without a parent Company). Also, CompanyExtra is optional so you can have a Company without any associated CompanyExtra during Company's lifecycle.
To me, it seems natural and logical that if you set Company.companyExtra to null, and save Company, Hibernate should automatically delete the associated record in the company_extra table if the delete-orphan cascade style is configured (which, of course, it not currently allowed). This is what I want to do when editing an existing Company instance:
aCompany = session.load(...);
aCompany.setCompanyExtra(null);
aCompany.setName("some new name");
session.save(aCompany); // automatically deletes company_extra record
For now, I think the workaround is to explicitly delete the CompanyExtra instance in Java code but that just doesn't seem natural to me and it isn't transparent. I do NOT want to do this:
aCompany = session.load(...);
companyExtra = aCompany.getCompanyExtra(); // ***extra, unnatural method call
aCompany.setCompanyExtra(null);
aCompany.setName("some new name");
session.save(aCompany);
session.delete(companyExtra); // ***another extra, unnatural method call
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (ANN-573) Many-to-many with Attributes (Attribute-class with two @ManyToOne mappings as @Id) not possible
by Christian Köberl (JIRA)
Many-to-many with Attributes (Attribute-class with two @ManyToOne mappings as @Id) not possible
-----------------------------------------------------------------------------------------------
Key: ANN-573
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-573
Project: Hibernate Annotations
Type: Bug
Components: binder
Versions: 3.2.1
Environment: Hibernate+Annotations 3.2.1-ga, HSQLDB 1.8.0.7
Reporter: Christian Köberl
Attachments: manytomanybug.zip
Im trying to map the following relation:
Order 1-n OrderLine m-1 Product
where the OrderLine contains an amount of the ordered product.
The problem seems to be multiple @Id in combination with @ManyToOne:
@Entity
@Table(name = "order_line")
// @IdClass(OrderLinePK.class)
public class OrderLine implements Serializable
{
@Id
@ManyToOne(targetEntity = Order.class)
@JoinColumn(name = "order_id", nullable = false)
private Order order;
@Id
@ManyToOne(targetEntity = Product.class)
@JoinColumn(name = "product_id", nullable = false)
...
}
Hibernate maps the OrderLine class in the following way:
DEBUG SchemaUpdate:149 - create table order_line (product varbinary(255) not null, order varbinary(255) not null, amount integer, primary key (order))
(maybe this relates to http://opensource.atlassian.com/projects/hibernate/browse/ANN-435)
When I add an IdClass to the OrderLine, I get the following exception:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: model.OrderLine.order in model.Order.lineItems
The example is attached as a runnable Maven2-Project, just run mvn test. The test dao.OrderDaoAnnotationTest fails.
In the project I also tried to map the same classes with hbm-Files and this works (dao.OrderDaoHbmTest).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
14 years, 2 months