[Hibernate-JIRA] Created: (HCANN-8) Hibernate allow to embed non embeddable class
by Maillefer Jean-David (JIRA)
Hibernate allow to embed non embeddable class
---------------------------------------------
Key: HCANN-8
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-8
Project: Hibernate Commons Annotations
Issue Type: Bug
Environment: JBoss-5.1.0.GA, postgresql 8.4.0
Reporter: Maillefer Jean-David
Priority: Minor
Hibernate allows to embed (successfully !) a non embeddable class (if it was embeddable, it would throw a compiler exception)
@Entity
public class BanqueId {
@Id
int id;
}
public class Compte{
@ManyToOne
@JoinColumn(name = "compte_banqueId_id", insertable = false, updatable = false)
private BanqueId banqueId;
@Column(name = "compte_iban", length = 30)
private String iban;
}
@Entity
public class Cotisation {
@Id
int id;
@Embedded
private Compte compte;
}
In this case, using @Embeddable on Compte yields the following compiler error: "Attribute "banqueId" has invalid mapping type in this context"
Not using this annotation (as in this example) generates (at least partially) working code, but seems not to follow the specification (ejb 3.0 spec persistance, 9.1.35) !
--
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, 10 months
[Hibernate-JIRA] Created: (HCANN-13) When mapping a domain on getter methods, if a @Formula is not in order with the other get methods, Hibernate generates an AND statement for the formula
by Fabio Schmitz Tani (JIRA)
When mapping a domain on getter methods, if a @Formula is not in order with the other get methods, Hibernate generates an AND statement for the formula
-------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HCANN-13
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-13
Project: Hibernate Commons Annotations
Issue Type: Bug
Environment: Oracle 10g, Hibernate 3
Reporter: Fabio Schmitz Tani
When mapping a domain on getter methods, if a @Formula is not in order with the other get methods, Hibernate generates an AND statement for the formula.
For example, a domain with 2 fields and a formula field:
<code>
private Integer id;
private String text;
private Integer countField;
@Id
@Column(name = "id")
public Integer getId()...
@Column(name = "text")
public String getText()...
public void setId(Integer id)...
public void setText(String txt)...
@Formula("(select count(*) from other table)")
public Integer getCount()...
public void setCount(Integer count)....
</code>
When searching with Criteria, Hibernate adds the Formula in the query as a requirement:
select this_.id, this_.txt, (select count(*) from other table) as count from table this_ where id = ? and ((select count(*) from other table)=?)
--
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, 10 months
[Hibernate-JIRA] Created: (HCANN-11) @Filter does throws expception when used on a join with an assiociation
by vamshi gunda (JIRA)
@Filter does throws expception when used on a join with an assiociation
-----------------------------------------------------------------------
Key: HCANN-11
URL: http://opensource.atlassian.com/projects/hibernate/browse/HCANN-11
Project: Hibernate Commons Annotations
Issue Type: Bug
Environment: hibernate 3.2.6.ga
Reporter: vamshi gunda
Hi,
I have an One to One association as shown below. But when i am saving the object, it throws me the following error.
The list "questionnaire" is in a class Section. I am trying to save a section object with a "ReportFormQuestion object" in it.
Please let me know if you need any details.
Thanks and regards
Vamshi Gunda
@OneToMany(cascade = {javax.persistence.CascadeType.ALL}, fetch = FetchType.LAZY)
@JoinTable(name = "questionnaire", joinColumns = @JoinColumn(name = "for_section"))
@Filter(name="excludeInactive")
private List<ReportFormQuestion> questionnaire = new ArrayList<ReportFormQuestion>();
org.hibernate.event.def.AbstractFlushingEventListener : Could not synchronize database state w
ith session
org.hibernate.HibernateException: cannot recreate collection while filter is enabled: [tavant.twms.domain.customReports.Report
Section.questionnaire#1100000002480]
at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:55)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:170)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:655)
at org.springframework.transaction.support.AbstractPlatformTransactionManager
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-3278) JPA query does not work on Derby when more than one entity has a column named DATE
by Felipe Leme (JIRA)
JPA query does not work on Derby when more than one entity has a column named DATE
----------------------------------------------------------------------------------
Key: HHH-3278
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3278
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6, Hibernate Annotations 3.3.0, Hibernate Entity Manager 3.3.1, Derby 10.4.1.3
Reporter: Felipe Leme
I have a relationship that is more like this (sorry, didn't have time to provide a simpler scenario):
- MP has a field/column called date
- MPHistory also have the same field
- there is a 1-N relationship between MP -> MPHistory
- the relationship has a @OrderBy("date") clause
When Hibernate starts using H2, everything works fine. But if I use Derby, I get the following exception:
Caused by: java.sql.SQLException: Column name 'DATE' appears more than once in the result of the query expression.
The bad SQL is the following:
Hibernate: select distinct agententit0_.id as id1_0_, mps1_.id as id0_1_, history2_.id as id3_2_, agententit0_.connected as connected1_0_, agententit0_.jmx_name as jmx4_1_0_, agententit0_.status as status1_0_, agententit0_.host_id as host10_1_0_, agententit0_.host as host1_0_, agententit0_.local as local1_0_, agententit0_.port as port1_0_, agententit0_.type as type1_0_, mps1_.date as date0_1_, mps1_.name as name0_1_, mps1_.value as value0_1_, mps1_.frequency_type as frequency5_0_1_, mps1_.is_full_mode as is6_0_1_, mps1_.is_historical as is7_0_1_, mps1_.is_normal_mode as is8_0_1_, mps1_.tolerance as tolerance0_1_, mps1_.is_summary_mode as is10_0_1_, mps1_.value_class as value11_0_1_, mps1_.info_id as info12_0_1_, mps1_.obj_id as obj13_0__, mps1_.id as id0__, history2_.date as date3_2_, history2_.value as value3_2_, history2_.value_class as value4_3_2_, history2_.mp_id as mp5_1__, history2_.id as id1__ from ggs_objects agententit0_ left outer join mps mps1_ on agententit0_.id=mps1_.obj_id left outer join mps_history history2_ on mps1_.id=history2_.mp_id where agententit0_.type in (108, 8) order by date asc
More specifically, the final 'order by date asc' should be 'order by history2_.date asc'.
Doing some debugging, I found the problem at org.hibernate.sql.Template, method isFunctionOrKeyword (line 304), which returns:
"(".equals(nextToken) ||
KEYWORDS.contains(lcToken) ||
functionRegistry.hasFunction(lcToken) ||
dialect.getKeywords().contains(lcToken) ||
FUNCTION_KEYWORDS.contains(lcToken);
The 3rd check ( dialect.getKeywords().contains(lcToken) ) returns true for Derby, then the whole method returns true, which in turns does not prepend the "$PlaceHolder$ (history2_, in this case), in the query:
else if (
isIdentifier(token, dialect) &&
!isFunctionOrKeyword(lcToken, nextToken, dialect, functionRegistry) // <<<<< THIS IS THE ISSUE >>>>
) {
result.append(TEMPLATE)
.append('.')
.append( dialect.quote(token) );
}
For now, I just removed the @OrderBy from my query (it's not really important in my case), but it looks like the Template method logic is wrong in this case.
PS: I initially open the same ticket at JBoss' site (http://jira.jboss.org/jira/browse/HIBERNATE-95) - my mistake, I guess I should have opened it here instead...
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-3576) out of memory
by sridhar (JIRA)
out of memory
-------------
Key: HHH-3576
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3576
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: windows 2003 Standard edition SP2
Reporter: sridhar
Attachments: hibernate.zip
Hibernate unable to use scrollable results and running out of memory for MS SQL Server 2005 and MySQL 5.0.
But it is working fine for Oracle 10G.
Problem Description:
===================
I have a table with 10 columns and one of them is blob field. this blob field contains binary information about 33KB.
I have 70,000 rows in database.
When I read the complete data using scrollable results implementation of hibernate, for Oracle 10G, the process completeed in 10 Seconds.
But when run the same program for MS SQL Server 2005 and MySQL 5.0 its running out of memory.
Steps to reproduc the problem:
=========================
I am enclosing the eclipse project. In the lib folder it contains the JDBC drivers for Oracle 10G, Mysql 5, MS SQL Server2005.
Remaing jar files will come with standard Springs distribution of 2.5.
import the project into eclipse.
Please configure the database details in jdbc.properties
now run the DBRead.java.
This will populate the 68828 records in the configured database and reads complete data from the database.
For MySQL and MS SQl Server it will give out of memory error while reading.
--
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, 10 months
[Hibernate-JIRA] Created: (HV-246) BeanValidationEventListener has a bug (technically a problem with hibernate-annotations 3.5.0beta1... but I couldn't find that project)
by Ken Egervari (JIRA)
BeanValidationEventListener has a bug (technically a problem with hibernate-annotations 3.5.0beta1... but I couldn't find that project)
---------------------------------------------------------------------------------------------------------------------------------------
Key: HV-246
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-246
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.0.0.CR1
Environment: hibernate 3.3.2ga, hibernate validator 4.0cr1, hibernate-annotations 3.5.0beta1
Reporter: Ken Egervari
Priority: Blocker
The interaction with a hibernate session and sessions created within a validator do not work together.
For example, here is a test case:
{code}
@Test
public void jobSeekersCanSaveAPreviousResumeWithTheSameName() {
JobSeekerResume resume = ( JobSeekerResume ) resumeDao.find( 1 );
resume.setDescription( "new desc." );
resumeDao.save( resume );
flush();
jdbcMap = simpleJdbcTemplate.queryForMap(
"select * from resume where resume_id = ?", resume.getId() );
assertEquals( resume.getDescription(), jdbcMap.get( "DESCRIPTION" ) );
}
{code}
the flush() method creates an exception:
{code}
ERROR AssertionFailure:45 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: collection [jawbs.domain.jobseeker.JobSeeker.categories] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:228)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:356)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at jawbs.DatabaseTests.flush(DatabaseTests.java:113)
{code}
Obviously hibernate core is saying this could be a bug, or it could be unsafe.
Now, the reason this happens is because JobSeekerResume has a contraint that accesses the hibernate session. Now, I have many, many constraints that use this constraint and they work fine. This is the only test that is causing problems for me, and I don't have a clue why.
Nonetheless, I'm going to give you a lot of code. Here is the constraint annotation on JobSeekerResume:
{code}
@QueryConstraint(
hql = "select count(*) from JobSeekerResume where name = :name and id != :id and jobSeeker.id = :jobSeeker.id",
message = "{jobSeekerResume.name.unique}",
enabled = true
)
{code}
And here is the code for the validator implementation:
{code}
public class QueryConstraintValidator extends ValidatorSupport<QueryConstraint,DomainObject> {
/* Fields */
private String hql;
private boolean enabled;
/* Services */
public void initialize( QueryConstraint queryConstraint ) {
this.hql = queryConstraint.hql();
this.enabled = queryConstraint.enabled();
}
public boolean isValid( DomainObject domainObject ) {
return isValid( domainObject, null );
}
@Override
protected boolean preValidate() {
return !enabled;
}
protected boolean testQuery( Session session, DomainObject domainObject ) {
logger.debug( "Enabled - Validating constraint with: " );
logger.debug( hql );
Query query = session.createQuery(
HqlParser.removePeriodsFromParameterNames( hql )
);
BeanWrapper beanWrapper = new BeanWrapperImpl( domainObject );
for( String parameterName : HqlParser.getParameterNames( hql ) ) {
query.setParameter(
HqlParser.removePeriodsFromParameterName( parameterName ),
beanWrapper.getPropertyValue( parameterName )
);
}
boolean result = (Long) query.uniqueResult() == 0;
logger.debug( "isValid is returning: " + result );
return result;
}
...
}
{code}
The support constraint (the important one most likely) is as follows:
{code}
public abstract class ValidatorSupport<T extends Annotation,U> implements ConstraintValidator<T,U> {
/* Fields */
protected static Logger logger =
LoggerFactory.getLogger( QueryConstraintValidator.class );
/* Services */
public boolean isValid( U object, ConstraintValidatorContext constraintValidatorContext ) {
if( preValidate() ) {
return true;
}
SessionFactory sessionFactory =
( SessionFactory ) ApplicationContextProvider.getBean(
"sessionFactory" );
if( sessionFactory != null ) {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
boolean result = testQuery( session, object );
tx.commit();
session.close();
return result;
}
return true;
}
protected boolean preValidate() {
return false;
}
protected abstract boolean testQuery( Session session, U object );
}
{code}
Lastly, here is the mapping of the JobSeeker subclass:
{code}
<subclass name="jawbs.domain.jobseeker.JobSeeker" discriminator-value="ROLE_JOBSEEKER">
<property name="isPrivate" column="is_private" />
<bag name="categories" table="job_seeker_to_category" cascade="all-delete-orphan" inverse="true">
<key column="job_seeker_id"/>
<many-to-many class="jawbs.domain.Category" column="category_id"/>
</bag>
<bag name="watchedJobs" table="job_seeker_to_watched_job" cascade="all-delete-orphan" inverse="true">
<key column="job_seeker_id"/>
<many-to-many class="jawbs.domain.job.Job" column="watched_job_id"/>
</bag>
<bag name="applications" table="candidate" cascade="all-delete-orphan" inverse="true">
<key column="job_seeker_id"/>
<many-to-many class="jawbs.domain.candidate.Candidate" column="candidate_id"/>
</bag>
<bag name="blacklistedEmployers" table="job_seeker_to_blacklisted_employer">
<key column="job_seeker_id"/>
<many-to-many class="jawbs.domain.employer.Employer" column="blacklisted_employer_id"/>
</bag>
<bag name="resumes" table="resume" inverse="true" cascade="all-delete-orphan">
<key column="job_seeker_id"/>
<one-to-many class="jawbs.domain.resume.Resume" />
</bag>
</subclass>
{code}
And here is the mapping of the subclass of resume:
{code}
<subclass name="jawbs.domain.resume.JobSeekerResume" discriminator-value="JOBSEEKER">
<many-to-one name="jobSeeker" class="jawbs.domain.jobseeker.JobSeeker"
column="job_seeker_id" />
</subclass>
{code}
If you need any more assistance, please let me know. This is a critical blocker to getting a test to pass, this is most likely 100% fine.
Thanks
--
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, 10 months