[Hibernate-JIRA] Created: (HHH-3246) Enhance Criteria#list to allow passing custom List instances
by Holger Haag (JIRA)
Enhance Criteria#list to allow passing custom List instances
------------------------------------------------------------
Key: HHH-3246
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3246
Project: Hibernate3
Issue Type: Improvement
Reporter: Holger Haag
Priority: Minor
Hello,
it would be great for us if Criteria#list allowed to pass instances of java.util.List:
Currently there is only
public List list();
This calls Session(Impl)#list, which initializes the list with CollectionHelper.EMPTY_LIST;.
What I'd like additionally is
public void list(final List list);
>From a first look at Criteria/CriteriaImpl, Session/SessionImpl that seems to be feasible, although I must admit that I'm not really familiar with the hibernate source code.
The reason behind this improvement request is that in our company we often have our own list classes extending ArrayList<sometype>. These customized list classes provide methods that would otherwise have to go into static utility classes, e.g. if there is a Price class, the PriceList class (extending ArrayList<Price>) provides a total() method.
So what we do to get a PriceList is
(1) list = crit.list()
(2) priceList = new PriceList()
(3) priceList.addAll(list)
which temporarily creates two lists, with one list being immediately discarded by garbage collection.
Any comments on that ?
Thanks in advance
Holger
--
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
16 years, 1 month
[Hibernate-JIRA] Created: (HHH-3245) Missing release from cache in "EntityInsertAction" during rollback.
by Alexander Krasnostavksy (JIRA)
Missing release from cache in "EntityInsertAction" during rollback.
-------------------------------------------------------------------
Key: HHH-3245
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3245
Project: Hibernate3
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6
Oracle 10.2.0.3.0
Reporter: Alexander Krasnostavksy
"EntityInsertAction" is missing release from a cache in the same way as it done in "EntityUpdateAction". This causes wrong behavior after rollback when generator class is "assigned" and cache usage is defined.
The cache handling should be like this:
if (persister.hasCache())
{
final CacheKey ck = new CacheKey(
getId(),
persister.getIdentifierType(),
persister.getRootEntityName(),
getSession().getEntityMode(),
getSession().getFactory()
);
if ( success && isCachePutEnabled( persister, getSession() ) ) {
boolean put = persister.getCache().afterInsert(ck, cacheEntry, version );
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
getSession().getFactory().getStatisticsImplementor()
.secondLevelCachePut( getPersister().getCache().getRegionName() );
}
}
else if (cacheEntry!=null) {
persister.getCache().release(ck, lock );
}
}
--
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
16 years, 1 month
[Hibernate-JIRA] Commented: (HBX-67) Add annotations to java templates
by miguel de anda (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-67?page=com... ]
miguel de anda commented on HBX-67:
-----------------------------------
That patch adds annotations for fields, getter methods and classes. See the following hbm sample for usage...
<hibernate-mapping>
<class name="blah.blah" table="tblVideo">
<meta attribute="class-description">
@author Miguel
</meta>
<meta attribute="class-annotation">@Class1</meta>
<meta attribute="class-annotation">@Class2</meta>
...
<property
name="title"
type="java.lang.String"
update="true"
insert="true"
access="property"
>
<meta attribute="field-description">this is a field description that miguel added</meta>
<meta attribute="field-annotation">@Field1</meta>
<meta attribute="field-annotation">@Field2</meta>
<meta attribute="getter-annotation">@Getter1</meta>
<meta attribute="getter-annotation">@Getter2</meta>
<column name="Title" sql-type="nvarchar2 (200)" />
</property>
...
I didn't add the annotations to getter because a) i was getting lazy, and b) haven't run into a need for it yet.
> Add annotations to java templates
> ---------------------------------
>
> Key: HBX-67
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-67
> Project: Hibernate Tools
> Issue Type: New Feature
> Reporter: Max Rydahl Andersen
>
> Need to add the basic jdk 1.5 annotations to the java velocity 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
16 years, 1 month
[Hibernate-JIRA] Commented: (HBX-67) Add annotations to java templates
by miguel de anda (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-67?page=com... ]
miguel de anda commented on HBX-67:
-----------------------------------
I couldn't figure out where the original bug was but I've created a fix for this. We need to get annotations to make our hbm2java objects searchable with hibernate-search. I had a hard time getting a clean `svn diff` as i have different line breaks (I think its the reason). Anyway, here is some info on what I did:
$svn info
Path: .
URL: http://anonsvn.jboss.org/repos/hibernate/trunk/HibernateExt/tools
Repository Root: http://anonsvn.jboss.org/repos/hibernate
Repository UUID: 1b8cb986-b30d-0410-93ca-fae66ebed9b2
Revision: 14513
Node Kind: directory
Schedule: normal
Last Changed Author: max.andersen(a)jboss.com
Last Changed Rev: 10633
Last Changed Date: 2006-10-19 10:38:50 -0700 (Thu, 19 Oct 2006)
$svn stat
? bin
M src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
M src/java/org/hibernate/tool/hbm2x/pojo/POJOClass.java
M src/templates/pojo/PojoFields.ftl
M src/templates/pojo/PojoTypeDeclaration.ftl
M src/templates/pojo/PojoPropertyAccessors.ftl
Additions or the entire file (as applicable)
src/java/org/hibernate/tool/hbm2x/pojo/POJOClass.java
+ public boolean hasFieldAnnotations(Property p);
+ public String getFieldAnnotations(Property p, int indent);
+ public boolean hasClassAnnotations();
+ public String getClassAnnotations(int indent);
+ public boolean hasGetterAnnotations(Property p);
+ public String getGetterAnnotations(Property p, int indent);
src/java/org/hibernate/tool/hbm2x/pojo/BasicPOJOClass.java
+import org.hibernate.tool.hbm2x.StringUtils;
...
+ private boolean hasPropertyAttribute(Property property, String attribute) {
+ return property!=null && property.getMetaAttribute(attribute)!=null;
+ }
+
+ private String getAnnotations(MetaAttribute c, int indent) {
+ StringBuffer sb = new StringBuffer();
+ Iterator it = c.getValues().iterator();
+ while (it.hasNext()) {
+ String v = (String)it.next();
+ sb.append(StringUtils.leftPad( v, v.length() + indent ));
+ if (it.hasNext())
+ sb.append("\n");
+ }
+ return sb.toString();
+ }
+
+ private String getAnnotations(Property property, String attribute, int indent) {
+ MetaAttribute c = property.getMetaAttribute( attribute );
+ if ( c == null ) {
+ return "";
+ } else {
+ return getAnnotations(c, indent);
+ }
+ }
+
+ public boolean hasClassAnnotations() {
+ return meta.getMetaAttribute( "class-annotation" ) != null;
+ }
+
+ public String getClassAnnotations(int indent) {
+ MetaAttribute c = meta.getMetaAttribute( "class-annotation" );
+ if ( c == null ) {
+ return "";
+ } else {
+ return getAnnotations(c, indent);
+ }
+ }
+
+ public boolean hasFieldAnnotations(Property property) {
+ return hasPropertyAttribute(property, "field-annotation");
+ }
+
+ public String getFieldAnnotations(Property property, int indent) {
+ return getAnnotations(property, "field-annotation", indent);
+ }
+
+ public boolean hasGetterAnnotations(Property property) {
+ return hasPropertyAttribute(property, "getter-annotation");
+ }
+
+ public String getGetterAnnotations(Property property, int indent) {
+ return getAnnotations(property, "getter-annotation", indent);
+ }
src/templates/pojo/PojoFields.ftl (entire file pasted)
// Fields
<#foreach field in pojo.getAllPropertiesIterator()><#if pojo.getMetaAttribAsBool(field, "gen-property", true)> <#if pojo.hasMetaAttribute(field, "field-description")> /**
${pojo.getFieldJavaDoc(field, 0)}
*/
</#if><#if pojo.hasFieldAnnotations(field)>
${pojo.getFieldAnnotations(field, 4)}
</#if> ${pojo.getFieldModifiers(field)} ${pojo.getJavaTypeName(field, jdk5)} ${field.name}<#if pojo.hasFieldInitializor(field, jdk5)> = ${pojo.getFieldInitialization(field, jdk5)}</#if>;
</#if>
</#foreach>
src/templates/pojo/PojoTypeDeclaration.ftl (entire file pasted)
/**
${pojo.getClassJavaDoc(pojo.getDeclarationName() + " generated by hbm2java", 0)}
*/<#if pojo.hasClassAnnotations()>
${pojo.getClassAnnotations(0)}
</#if>
<#include "Ejb3TypeDeclaration.ftl"/>
${pojo.getClassModifiers()} ${pojo.getDeclarationType()} ${pojo.getDeclarationName()} ${pojo.getExtendsDeclaration()} ${pojo.getImplementsDeclaration()}
src/templates/pojo/PojoPropertyAccessors.ftl (entire file pasted)
// Property accessors
<#foreach property in pojo.getAllPropertiesIterator()>
<#if pojo.getMetaAttribAsBool(property, "gen-property", true)>
<#if pojo.hasFieldJavaDoc(property)>
/**
${pojo.getFieldJavaDoc(property, 4)}
*/
</#if>
<#if pojo.hasGetterAnnotations(property)>
${pojo.getGetterAnnotations(property, 4)}
</#if>
<#include "Ejb3PropertyGetAnnotation.ftl"/>
${pojo.getPropertyGetModifiers(property)} ${pojo.getJavaTypeName(property, jdk5)} ${pojo.getGetterSignature(property)}() {
return this.${property.name};
}
${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}(${pojo.getJavaTypeName(property, jdk5)} ${property.name}) {
this.${property.name} = ${property.name};
}
</#if>
</#foreach>
> Add annotations to java templates
> ---------------------------------
>
> Key: HBX-67
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-67
> Project: Hibernate Tools
> Issue Type: New Feature
> Reporter: Max Rydahl Andersen
>
> Need to add the basic jdk 1.5 annotations to the java velocity 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
16 years, 1 month