[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
[Hibernate-JIRA] Commented: (HHH-1501) Derby 10 varchar limit is 32672
by Beta (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1501?page=c... ]
Beta commented on HHH-1501:
---------------------------
I have this problem fixed by using "long varchar" (it's for strings of any length). I have tested it with a column of 64k and it worked great.
Here is the code:
registerColumnType(Types.VARCHAR, 32672, "varchar($l)");
registerColumnType(Types.VARCHAR, Integer.MAX_VALUE, "long varchar");
I think the best would be to add this code to the DerbyDialect.java
> Derby 10 varchar limit is 32672
> --------------------------------
>
> Key: HHH-1501
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1501
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.2
> Environment: Derby 10
> Reporter: Sergey Vladimirov
> Priority: Trivial
>
> Derby 10 varchar limit is 32672.
> One need to change DB2Dialect and DerbyDialect to create clob columns, if size of text > 32k:
> registerColumnType(Types.CHAR, 254, "char(1)");
> registerColumnType(Types.VARCHAR, 32672, "varchar($l)");
> registerColumnType(Types.VARCHAR, Integer.MAX_VALUE, "clob($l)");
> (BTW, char limit is 254).
--
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
[Hibernate-JIRA] Commented: (HHH-1685) DetachedCriteria doesn't create alias on subcriteria
by Rastislav Siekel (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685?page=c... ]
Rastislav Siekel commented on HHH-1685:
---------------------------------------
I find this correction just now, because I have some new requirements to this part of code, and all go perfect. Thank's very much :-)
> DetachedCriteria doesn't create alias on subcriteria
> ----------------------------------------------------
>
> Key: HHH-1685
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.2.5
> Reporter: John
> Assignee: Diego Plentz
> Fix For: 3.2.6
>
> Attachments: hhh1685-example.txt
>
>
> DetachedCriteria has two createCriteria methods:
> public DetachedCriteria createCriteria(String associationPath) throws HibernateException
> public DetachedCriteria createCriteria(String associationPath, String alias) throws HibernateException
> However, the code for both was identical - they called the inner criteria's createCriteria(String) method. The version with the alias did not call the inner's version with the alias. The following patch snipped shows the change:
> public DetachedCriteria createCriteria(String associationPath, String alias)
> throws HibernateException {
> - return new DetachedCriteria( impl, criteria.createCriteria(associationPath) );
> + return new DetachedCriteria( impl, criteria.createCriteria(associationPath, alias) );
> }
> This bug was discovered while trying to link a 2-deep subquery to its parent via aliases. (Surfacing this issue might only be possible with the patch HHH-952 in place - I'm not sure. Seems like a bug regardless, as it definitely fixed my alias reference issue.) I'll get an example posted shortly.
--
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
[Hibernate-JIRA] Created: (HV-235) More useful exception error messages
by Ken Egervari (JIRA)
More useful exception error messages
------------------------------------
Key: HV-235
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-235
Project: Hibernate Validator
Issue Type: Improvement
Affects Versions: 4.0.0.CR1
Reporter: Ken Egervari
Hi, i know you are aware of this for version 3.1, but the problem has become even worse in 4.0 CR1.
Whenever an example is thrown, it looks like this:
javax.validation.ConstraintViolationException: Invalid object at persist time for groups [javax.validation.groups.Default, ]
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:83)
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:51)
at org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:142)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:65)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:538)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:530)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:526)
at org.springframework.orm.hibernate3.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:740)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:737)
Now, as I mentioned before, this gives unit tests absolutely no clue what the problem is. You see, when people get these exceptions... it's just not when they are testing their constraints - it's when they are testing their database, or their controllers. Usually the point of these tests is to test OTHER things, not the constraints. Yes, I am happy they are working nicely... but my main objective is to quickly fix the bean so the constraint doesn't fail and go along my merry way.
As it stands, these error messages are a pain in the rear. It's even worse now because you're not even telling us which object it occured on... so if we stored an object with lots of cascading children, there is no telling what the heck went wrong.
In a unit test, this is a very common idiom:
try {
userAccountDao.save( userAccount );
clear();
} catch( ConstraintViolationException e ) {
for( ConstraintViolation constraintViolation : e.getConstraintViolations() ) {
System.out.println( constraintViolation.getMessage() );
System.out.println( constraintViolation.getInvalidValue() );
System.out.println( constraintViolation.getLeafBean() );
System.out.println( constraintViolation.getMessageTemplate() );
System.out.println( constraintViolation.getConstraintDescriptor() );
System.out.println( constraintViolation.getPropertyPath() );
System.out.println( constraintViolation.getRootBeanClass() );
}
}
This is just trash code to write every time a constraint unmistakably gets violated. I tried in Junit... and there's no way to wrap a test method with another method to catch the exception and print this - like an aop around my unit tests.
Now, there are 2 solutions.
1) Rewrite the example to something like this:
javax.validation.ConstraintViolationException: object of class jawbs.domain.user.UserAccount has constraint violations [ ( property: "emailAddress", message: "Must be a valid email address" ) ]
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:83)
at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:51)
at org.hibernate.action.EntityIdentityInsertAction.preInsert(EntityIdentityInsertAction.java:142)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:65)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
....
2) Have an option on the validation factory in Hibernate (i.e. not using build default validator) to throw custom exceptions instead of the "standard" one. The custom one can even be provided by the library.
The idea is that the developer shouldn't have to go through all these hoops just to see error messages. Viewing the details of errors messages has been around in other frameworks just fine. As it stands, this feature makes this library/framework very, very, very, very frustrating to deal with. The actual error you guys are throwing... or the genuises who wrote the standard... is the most useless exception I've read all year.
I'm sorry to be aggressive on this... I'm just so frustrated with it. Like REALLY frustrated. I feel so powerless in that it's a part of your code I can't just swap out easily without recompiling it. And I don't think that's the right solution.
3) If there has to be workaround, please make it a HUGE point in the 4.0 GA documentation. Make sure people know about it and don't have to hunt down for it.
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
15 years
[Hibernate-JIRA] Created: (HHH-3917) @NotFound(action=NotFoundAction.IGNORE) results in EAGER loading for @ManyToOne(fetch = FetchType.LAZY) field
by Vlasov Igor (JIRA)
@NotFound(action=NotFoundAction.IGNORE) results in EAGER loading for @ManyToOne(fetch = FetchType.LAZY) field
-------------------------------------------------------------------------------------------------------------
Key: HHH-3917
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3917
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: Vlasov Igor
Hello
I try to use @org.hibernate.annotations.NotFound(action=NotFoundAction.IGNORE) annotation to avoid of throwing an exception IN
@JoinColumn(name = "UR_ID", referencedColumnName = "UR_ID")
@ManyToOne(fetch = FetchType.LAZY)
@org.hibernate.annotations.NotFound(action=NotFoundAction.IGNORE)
@Basic(optional=true)
private UserRole role;
Then it results me to EAGER loading of this field.
Throw days of debuging i have found that:
1. @org.hibernate.annotations.NotFound results in:
isNullable()=true
for org.hibernate.type.ManyToOneType
2. in org.hibernate.impl.SessionImpl and method internalLoad i can see:
LoadEventListener.LoadType type = nullable ?
LoadEventListener.INTERNAL_LOAD_NULLABLE :
eager ? LoadEventListener.INTERNAL_LOAD_EAGER : LoadEventListener.INTERNAL_LOAD_LAZY;
Threrefore we have LoadEventListener.INTERNAL_LOAD_NULLABLE type of loading my relation. !!!
and in class org.hibernate.event.LoadEventListener.INTERNAL_LOAD_NULLABLE I can see setAllowProxyCreation(false) !!!!
3. in org.hibernate.event.def.DefaultLoadEventListener in line 218 there is a condition:
if ( options.isAllowProxyCreation() ) {
return createProxyIfNecessary( event, persister, keyToLoad, options, persistenceContext );
} else {
return load(event, persister, keyToLoad, options);
}
In my case LoadEventListener.INTERNAL_LOAD_NULLABLE.isAllowProxyCreation() ==false !!
and it results in LOADING of Object !!!
Can we set LoadEventListener.INTERNAL_LOAD_NULLABLE.isAllowProxyCreation() to true ?
org.hibernate.event.LoadEventListener.INTERNAL_LOAD_NULLABLE = new LoadType("INTERNAL_LOAD_NULLABLE")
.setAllowNulls(true)
.setAllowProxyCreation(false)
.setCheckDeleted(false)
.setNakedEntityReturned(false);
--
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