[Hibernate-JIRA] Created: (ANN-626) @Generated annotation not inserting during insert
by Rob (JIRA)
@Generated annotation not inserting during insert
-------------------------------------------------
Key: ANN-626
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-626
Project: Hibernate Annotations
Issue Type: Bug
Affects Versions: 3.3.0.ga, 3.2.0.ga
Environment: MSSQL 9.00.3042.00
Hibernate annotations version 3.2.0 GA and also tested 3.30 GA
Reporter: Rob
Priority: Critical
The @Generated annotation is not working similiar to the hbm generated tag.
Annotation Mapping:
@Generated(GenerationTime.INSERT)
@Column (name="CreatedOn", length=23, nullable=false, insertable=false, updatable=false)
private Date mCreatedOn;
Mapping Document:
<property name="createdOn" generated="insert" type="TimestampType">
<column name="CreatedOn" length="23"/>
</property>
The generated SQL (show_sql=true):
Hibernate: insert into Zone (CreatedByUserID, ZoneDescription, ZoneFile, ModifiedByUserID, ModifiedOn, ZoneName, RowStatus, SOAExpire, SOAMinimum, SOARefresh, SOARetry, SOAWho, ZoneTTL, ZoneType, ZoneClass) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:
18:37:42 WARN org.hibernate.util.JDBCExceptionReporter 77 SQL Error: 515, SQLState: 23000
18:37:42 ERROR org.hibernate.util.JDBCExceptionReporter 78 Cannot insert the value NULL into column 'CreatedOn', table 'DB.dbo.Zone'; column does not allow nulls. INSERT fails.
--
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
15 years, 3 months
[Hibernate-JIRA] Created: (HBX-970) POJO generation should have full contructor as an option
by Alberto A. Flores (JIRA)
POJO generation should have full contructor as an option
--------------------------------------------------------
Key: HBX-970
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-970
Project: Hibernate Tools
Issue Type: Bug
Components: hbm2java, reverse-engineer
Affects Versions: 3.2beta9
Environment: Hibernate3, Oracle 10g
Reporter: Alberto A. Flores
When using hbm2java (for reverse engineering the database to generate POJOs), there is no real way to declare full constructor generation as an option (which is not required in Hibernate anyway). In a large table, I found the error of "can't create a constructor with more than 255 parameters" (which could easily grow if you use inheritance). We had to fix the PojoContructors.ftl code to never generate that full contructor.
Potential fixes:
- Find a way to initialize the BasicPojoClass to initialize the needFullContructor using <property> in the hbm2java
- Using the <property> feature within hbm2java, fix the PojoConstructor.ftl to check for a variable that is (optionally) visible by virtue of the <property> tag instead of always checking for "pojo.needFullConstructor"
- Provide a way to replace BasicPojoClass as part of the hbm2java task. By default, this uses the hardcoded code to always use this template.
--
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
15 years, 3 months
[Hibernate-JIRA] Created: (ANN-548) Joins break when using composite primary key classes
by Vincent Jenks (JIRA)
Joins break when using composite primary key classes
----------------------------------------------------
Key: ANN-548
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-548
Project: Hibernate Annotations
Type: Bug
Versions: 3.2.1, 3.2.2
Environment: JBoss 4.0.5.GA w/ Hibernate 3.2.2 and Annoations 3.2.2 (from SVN). Also reproduced w/ JBoss 4.0.5.GA w/ stock annotations, hibernate, and entity manager, unmodified. The attached test-case was run against MSSQL 2000 but is trivial to point at another database. The issue was also reproduced on a OpenEdge Progress 10.1A database.
Reporter: Vincent Jenks
Attachments: CarBean.java, Carz.java, Lotz.java
Joins break when using composite primary key classes
JBoss 4.0.5.GA w/ Hibernate 3.2.2 and Annoations 3.2.2 (from SVN). Also reproduced w/ JBoss 4.0.5.GA w/ stock annotations, hibernate, and entity manager, unmodified. The attached test-case was run against MSSQL 2000 but is trivial to point at another database. The issue was also reproduced on a OpenEdge Progress 10.1A database.
In a case where there are composite keys on one (or each) side of a relationship, Hibernate cannot join the entities together if all of the primary key fields are not used in the relationship.
A (very) simple example, two entities Carz and Lotz (pardon the names, it's simply cars and car lots):
@Entity
@Table(name="car")
public class Carz implements Serializable
{
@Id
private Integer id;
@Column(name="make", nullable=false)
private String make;
@Column(name="model", nullable=false)
private String model;
@Column(name="manufactured", nullable=false)
@Temporal(TemporalType.TIMESTAMP)
private Date manufactured;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumns //Hibernate docs state that @JoinColumns must be used since Lotz has composite PK, a single @JoinColumn does not deploy anyhow
({
@JoinColumn(name="loc_code", referencedColumnName="loc_code", insertable=false, updatable=false)
})
private Lotz lot;
...........................
}
@Entity
@Table(name="lot")
public class Lotz implements Serializable
{
@EmbeddedId
protected LotzPK lotPK;
@Column(name="name", nullable=false)
private String name;
@Column(name="location", nullable=false)
private String location;
@OneToMany(mappedBy="lot", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
private List<Carz> cars;
...........................
}
@Embeddable
public class LotzPK implements Serializable
{
@Column(name="id", nullable=false)
private Integer id;
@Column(name="loc_code", nullable=false)
private String locCode;
...........................
}
In this case I need a one-to-many relationship on Carz.id = Lotz.locCode. However, there doesn't appear to be a way to do this.
When this is deployed, this exception occurs:
org.hibernate.AnnotationException: Column name id of hqb.model.Lotz not found in JoinColumns.referencedColumnName
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:306)
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:64)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:433)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:287)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1211)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:847)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:102)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
at sun.reflect.GeneratedMethodAccessor263.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
...........................
I can deploy the app if I map both fields in the Lotz PK class like so:
@Entity
@Table(name="car")
public class Carz implements Serializable
{
@Id
private Integer id;
...........................
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumns
({
@JoinColumn(name="loc_code", referencedColumnName="loc_code", insertable=false, updatable=false),
@JoinColumn(name="", referencedColumnName="id", insertable=false, updatable=false) //INCORRECTLY DEFINED RELATIONSHIP!
})
private Lotz lot;
...........................
}
But obviously this is no good, it generates bad SQL at runtime:
/* select
c
from
Carz c
left join
fetch c.lot */ select
carz0_.id as id198_0_,
lotz1_.id as id199_1_,
lotz1_.loc_code as loc2_199_1_,
carz0_.make as make198_0_,
carz0_.model as model198_0_,
carz0_.manufactured as manufact4_198_0_,
carz0_.lot_id as lot5_198_0_,
carz0_.loc_code as loc6_198_0_, --no such column...
lotz1_.name as name199_1_,
lotz1_.location as location199_1_
from
car carz0_
left outer join
lot lotz1_
on carz0_.lot_id=lotz1_.id --oops! Hibernate defaulted a relationship here...
and carz0_.loc_code=lotz1_.loc_code
In reality, this is the SQL I'm trying to achieve, by repairing the above query manually:
select
carz0_.id as id198_0_,
lotz1_.id as id199_1_,
lotz1_.loc_code as loc2_199_1_,
carz0_.make as make198_0_,
carz0_.model as model198_0_,
carz0_.manufactured as manufact4_198_0_,
carz0_.loc_code as loc6_198_0_,
lotz1_.name as name199_1_,
lotz1_.location as location199_1_
from
car carz0_
left outer join
lot lotz1_
on carz0_.loc_code=lotz1_.loc_code
This is consistent w/ the EJB 3.0 spec (and Glassfish+Toplink) but that's only because the spec doesn't define exacltly how to handle this. However, that being said, this seems important enough for Hibernate to be able to manage?
--
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
15 years, 3 months
[Hibernate-JIRA] Created: (EJB-315) unnecessary update when merge managed entity
by Jifeng Liu (JIRA)
unnecessary update when merge managed entity
--------------------------------------------
Key: EJB-315
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-315
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.3.1.GA
Environment: Hibernate Core 3.2.5.ga
Hibernate Annotations 3.3.0 GA
hsqldb
Reporter: Jifeng Liu
Attachments: testcase.zip
If the entity in em.merge(entity) is managed entity, the merge operation should be ignored. However it issues a update statement in the test case even if there is no changes.
In the test case, Parent entity has a list of Image entity with Many-To-Many relation. em.merge() somehow marks the list as dirty, which causes the update statement.
The following is trace log of the test case.
07.20,23 INFO ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
07.20,601 DEBUG SQL - /* insert test.Parent */ insert into Parent (updateDateTime, Parent_No) values (?, ?)
07.20,617 DEBUG SQL - /* insert test.Image */ insert into Image (name, imageNo) values (?, ?)
07.20,617 DEBUG SQL - /* insert collection row test.Parent.images */ insert into Parent_Image (Parent_Parent_No, images_
imageNo) values (?, ?)
07.20,632 DEBUG SQL - /* load test.Parent */ select parent0_.Parent_No as Parent1_0_0_, parent0_.updateDateTime as updat
eDa2_0_0_ from Parent parent0_ where parent0_.Parent_No=?
07.20,648 DEBUG SQL - /* load collection test.Parent.images */ select images0_.Parent_Parent_No as Parent1_1_, images0_.
images_imageNo as images2_1_, image1_.imageNo as imageNo1_0_, image1_.name as name1_0_ from Parent_Image images0_ left o
uter join Image image1_ on images0_.images_imageNo=image1_.imageNo where images0_.Parent_Parent_No=?
07.20,679 DEBUG SQL - /* update test.Parent */ update Parent set updateDateTime=? where Parent_No=? and updateDateTime=?
07.20,679 DEBUG SQL - /* delete collection test.Parent.images */ delete from Parent_Image where Parent_Parent_No=?
07.20,679 DEBUG SQL - /* insert collection row test.Parent.images */ insert into Parent_Image (Parent_Parent_No, images_
imageNo) values (?, ?)
--
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
15 years, 5 months
[Hibernate-JIRA] Created: (HHH-2830) Insert error ignored when using sybase generated identity column
by Martin van Dijken (JIRA)
Insert error ignored when using sybase generated identity column
----------------------------------------------------------------
Key: HHH-2830
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2830
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: Hibernate 3.2.2, Sybase 12.5.3
Reporter: Martin van Dijken
All our tables have a single database generated identity column. This column is specified in Sybase as:
objectId numeric(12) identity
A little while ago, Hibernate started throwing NonUniqueObjectExceptions upon insert of a certain object. It turns out, the insert statement could not possibly succeed as the value of one of the columns was larger than the database column. The error is however ignored because Hibernate generates a query:
insert into objectTable (objectName, objectNumericErrorField) values (?,?) select @@ identity
The value of objectNumericErrorField was larger than the database column allows. The insert statement would therefore fail. The select @@identity however would succeed, only because no new row was inserted it would return the previous ID.
Hibernate then assumes the entire query worked fine and would assign the already assigned id to a different object. It would then check whether or not the id was already in use and throw a NonUniqueObjectException
--
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
15 years, 5 months