Hibernate SVN: r18024 - core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-11-23 10:43:31 -0500 (Mon, 23 Nov 2009)
New Revision: 18024
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
Log:
An error message (instead of an NPE) when a suprclass of an audited entity is not audited
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-11-23 11:38:18 UTC (rev 18023)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-11-23 15:43:31 UTC (rev 18024)
@@ -273,7 +273,14 @@
// Getting the property mapper of the parent - when mapping properties, they need to be included
String parentEntityName = pc.getSuperclass().getEntityName();
- ExtendedPropertyMapper parentPropertyMapper = entitiesConfigurations.get(parentEntityName).getPropertyMapper();
+
+ EntityConfiguration parentConfiguration = entitiesConfigurations.get(parentEntityName);
+ if (parentConfiguration == null) {
+ throw new MappingException("Entity '" + pc.getEntityName() + "' is audited, but its superclass: '" +
+ parentEntityName + "' is not.");
+ }
+
+ ExtendedPropertyMapper parentPropertyMapper = parentConfiguration.getPropertyMapper();
ExtendedPropertyMapper propertyMapper = new SubclassPropertyMapper(new MultiPropertyMapper(), parentPropertyMapper);
return Triple.make(class_mapping, propertyMapper, parentEntityName);
15 years
Hibernate SVN: r18023 - beanvalidation/tck/trunk/src/main/resources.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-11-23 06:38:18 -0500 (Mon, 23 Nov 2009)
New Revision: 18023
Added:
beanvalidation/tck/trunk/src/main/resources/readme.txt
beanvalidation/tck/trunk/src/main/resources/validation-api.sig
Log:
BVTCK-4
Added: beanvalidation/tck/trunk/src/main/resources/readme.txt
===================================================================
--- beanvalidation/tck/trunk/src/main/resources/readme.txt (rev 0)
+++ beanvalidation/tck/trunk/src/main/resources/readme.txt 2009-11-23 11:38:18 UTC (rev 18023)
@@ -0,0 +1,10 @@
+Notes on using SigTest
+-----------------------------------------
+Sigtest home page: https://sigtest.dev.java.net/
+User Guide: http://java.sun.com/javame/sigtest/docs/sigtest2.1_usersguide.pdf
+
+Generating a signature file
+---------------------------
+To generate a signature file, use the following command:
+
+java -jar sigtestdev.jar Setup -classpath $JAVA_HOME/jre/lib/rt.jar:validation-api.jar -filename validation-api.sig -package javax.validation
Added: beanvalidation/tck/trunk/src/main/resources/validation-api.sig
===================================================================
--- beanvalidation/tck/trunk/src/main/resources/validation-api.sig (rev 0)
+++ beanvalidation/tck/trunk/src/main/resources/validation-api.sig 2009-11-23 11:38:18 UTC (rev 18023)
@@ -0,0 +1,625 @@
+#Signature file v4.0
+#Version
+
+CLSS public abstract interface java.io.Serializable
+
+CLSS public abstract interface java.lang.Comparable<%0 extends java.lang.Object>
+meth public abstract int compareTo({java.lang.Comparable%0})
+
+CLSS public abstract java.lang.Enum<%0 extends java.lang.Enum<{java.lang.Enum%0}>>
+cons protected Enum(java.lang.String,int)
+intf java.io.Serializable
+intf java.lang.Comparable<{java.lang.Enum%0}>
+meth protected final java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth public final boolean equals(java.lang.Object)
+meth public final int compareTo({java.lang.Enum%0})
+meth public final int hashCode()
+meth public final int ordinal()
+meth public final java.lang.Class<{java.lang.Enum%0}> getDeclaringClass()
+meth public final java.lang.String name()
+meth public java.lang.String toString()
+meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String)
+supr java.lang.Object
+hfds name,ordinal
+
+CLSS public java.lang.Exception
+cons public Exception()
+cons public Exception(java.lang.String)
+cons public Exception(java.lang.String,java.lang.Throwable)
+cons public Exception(java.lang.Throwable)
+supr java.lang.Throwable
+hfds serialVersionUID
+
+CLSS public abstract interface java.lang.Iterable<%0 extends java.lang.Object>
+meth public abstract java.util.Iterator<{java.lang.Iterable%0}> iterator()
+
+CLSS public java.lang.Object
+cons public Object()
+meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
+meth protected void finalize() throws java.lang.Throwable
+meth public boolean equals(java.lang.Object)
+meth public final java.lang.Class<?> getClass()
+meth public final void notify()
+meth public final void notifyAll()
+meth public final void wait() throws java.lang.InterruptedException
+meth public final void wait(long) throws java.lang.InterruptedException
+meth public final void wait(long,int) throws java.lang.InterruptedException
+meth public int hashCode()
+meth public java.lang.String toString()
+
+CLSS public java.lang.RuntimeException
+cons public RuntimeException()
+cons public RuntimeException(java.lang.String)
+cons public RuntimeException(java.lang.String,java.lang.Throwable)
+cons public RuntimeException(java.lang.Throwable)
+supr java.lang.Exception
+hfds serialVersionUID
+
+CLSS public java.lang.Throwable
+cons public Throwable()
+cons public Throwable(java.lang.String)
+cons public Throwable(java.lang.String,java.lang.Throwable)
+cons public Throwable(java.lang.Throwable)
+intf java.io.Serializable
+meth public java.lang.StackTraceElement[] getStackTrace()
+meth public java.lang.String getLocalizedMessage()
+meth public java.lang.String getMessage()
+meth public java.lang.String toString()
+meth public java.lang.Throwable fillInStackTrace()
+meth public java.lang.Throwable getCause()
+meth public java.lang.Throwable initCause(java.lang.Throwable)
+meth public void printStackTrace()
+meth public void printStackTrace(java.io.PrintStream)
+meth public void printStackTrace(java.io.PrintWriter)
+meth public void setStackTrace(java.lang.StackTraceElement[])
+supr java.lang.Object
+hfds backtrace,cause,detailMessage,serialVersionUID,stackTrace
+
+CLSS public abstract interface java.lang.annotation.Annotation
+meth public abstract boolean equals(java.lang.Object)
+meth public abstract int hashCode()
+meth public abstract java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
+meth public abstract java.lang.String toString()
+
+CLSS public abstract interface !annotation java.lang.annotation.Documented
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE])
+intf java.lang.annotation.Annotation
+
+CLSS public abstract interface !annotation java.lang.annotation.Retention
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE])
+intf java.lang.annotation.Annotation
+meth public abstract java.lang.annotation.RetentionPolicy value()
+
+CLSS public abstract interface !annotation java.lang.annotation.Target
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE])
+intf java.lang.annotation.Annotation
+meth public abstract java.lang.annotation.ElementType[] value()
+
+CLSS public abstract interface javax.validation.Configuration<%0 extends javax.validation.Configuration<{javax.validation.Configuration%0}>>
+meth public abstract javax.validation.ConstraintValidatorFactory getDefaultConstraintValidatorFactory()
+meth public abstract javax.validation.MessageInterpolator getDefaultMessageInterpolator()
+meth public abstract javax.validation.TraversableResolver getDefaultTraversableResolver()
+meth public abstract javax.validation.ValidatorFactory buildValidatorFactory()
+meth public abstract {javax.validation.Configuration%0} addMapping(java.io.InputStream)
+meth public abstract {javax.validation.Configuration%0} addProperty(java.lang.String,java.lang.String)
+meth public abstract {javax.validation.Configuration%0} constraintValidatorFactory(javax.validation.ConstraintValidatorFactory)
+meth public abstract {javax.validation.Configuration%0} ignoreXmlConfiguration()
+meth public abstract {javax.validation.Configuration%0} messageInterpolator(javax.validation.MessageInterpolator)
+meth public abstract {javax.validation.Configuration%0} traversableResolver(javax.validation.TraversableResolver)
+
+CLSS public abstract interface !annotation javax.validation.Constraint
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE])
+intf java.lang.annotation.Annotation
+meth public abstract java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy()
+
+CLSS public javax.validation.ConstraintDeclarationException
+cons public ConstraintDeclarationException()
+cons public ConstraintDeclarationException(java.lang.String)
+cons public ConstraintDeclarationException(java.lang.String,java.lang.Throwable)
+cons public ConstraintDeclarationException(java.lang.Throwable)
+supr javax.validation.ValidationException
+
+CLSS public javax.validation.ConstraintDefinitionException
+cons public ConstraintDefinitionException()
+cons public ConstraintDefinitionException(java.lang.String)
+cons public ConstraintDefinitionException(java.lang.String,java.lang.Throwable)
+cons public ConstraintDefinitionException(java.lang.Throwable)
+supr javax.validation.ValidationException
+
+CLSS public abstract interface javax.validation.ConstraintValidator<%0 extends java.lang.annotation.Annotation, %1 extends java.lang.Object>
+meth public abstract boolean isValid({javax.validation.ConstraintValidator%1},javax.validation.ConstraintValidatorContext)
+meth public abstract void initialize({javax.validation.ConstraintValidator%0})
+
+CLSS public abstract interface javax.validation.ConstraintValidatorContext
+innr public abstract interface static ConstraintViolationBuilder
+meth public abstract java.lang.String getDefaultConstraintMessageTemplate()
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder buildConstraintViolationWithTemplate(java.lang.String)
+meth public abstract void disableDefaultConstraintViolation()
+
+CLSS public abstract interface static javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder
+innr public abstract interface static NodeBuilderCustomizableContext
+innr public abstract interface static NodeBuilderDefinedContext
+innr public abstract interface static NodeContextBuilder
+meth public abstract javax.validation.ConstraintValidatorContext addConstraintViolation()
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderDefinedContext addNode(java.lang.String)
+
+CLSS public abstract interface static javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderCustomizableContext
+meth public abstract javax.validation.ConstraintValidatorContext addConstraintViolation()
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String)
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeContextBuilder inIterable()
+
+CLSS public abstract interface static javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderDefinedContext
+meth public abstract javax.validation.ConstraintValidatorContext addConstraintViolation()
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String)
+
+CLSS public abstract interface static javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeContextBuilder
+meth public abstract javax.validation.ConstraintValidatorContext addConstraintViolation()
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderCustomizableContext addNode(java.lang.String)
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderDefinedContext atIndex(java.lang.Integer)
+meth public abstract javax.validation.ConstraintValidatorContext$ConstraintViolationBuilder$NodeBuilderDefinedContext atKey(java.lang.Object)
+
+CLSS public abstract interface javax.validation.ConstraintValidatorFactory
+meth public abstract <%0 extends javax.validation.ConstraintValidator<?,?>> {%%0} getInstance(java.lang.Class<{%%0}>)
+
+CLSS public abstract interface javax.validation.ConstraintViolation<%0 extends java.lang.Object>
+meth public abstract java.lang.Class<{javax.validation.ConstraintViolation%0}> getRootBeanClass()
+meth public abstract java.lang.Object getInvalidValue()
+meth public abstract java.lang.Object getLeafBean()
+meth public abstract java.lang.String getMessage()
+meth public abstract java.lang.String getMessageTemplate()
+meth public abstract javax.validation.Path getPropertyPath()
+meth public abstract javax.validation.metadata.ConstraintDescriptor<?> getConstraintDescriptor()
+meth public abstract {javax.validation.ConstraintViolation%0} getRootBean()
+
+CLSS public javax.validation.ConstraintViolationException
+cons public ConstraintViolationException(java.lang.String,java.util.Set<javax.validation.ConstraintViolation<?>>)
+cons public ConstraintViolationException(java.util.Set<javax.validation.ConstraintViolation<?>>)
+meth public java.util.Set<javax.validation.ConstraintViolation<?>> getConstraintViolations()
+supr javax.validation.ValidationException
+hfds constraintViolations
+
+CLSS public javax.validation.GroupDefinitionException
+cons public GroupDefinitionException()
+cons public GroupDefinitionException(java.lang.String)
+cons public GroupDefinitionException(java.lang.String,java.lang.Throwable)
+cons public GroupDefinitionException(java.lang.Throwable)
+supr javax.validation.ValidationException
+
+CLSS public abstract interface !annotation javax.validation.GroupSequence
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE])
+intf java.lang.annotation.Annotation
+meth public abstract java.lang.Class<?>[] value()
+
+CLSS public abstract interface javax.validation.MessageInterpolator
+innr public abstract interface static Context
+meth public abstract java.lang.String interpolate(java.lang.String,javax.validation.MessageInterpolator$Context)
+meth public abstract java.lang.String interpolate(java.lang.String,javax.validation.MessageInterpolator$Context,java.util.Locale)
+
+CLSS public abstract interface static javax.validation.MessageInterpolator$Context
+meth public abstract java.lang.Object getValidatedValue()
+meth public abstract javax.validation.metadata.ConstraintDescriptor<?> getConstraintDescriptor()
+
+CLSS public abstract interface !annotation javax.validation.OverridesAttribute
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault int constraintIndex()
+meth public abstract java.lang.Class<? extends java.lang.annotation.Annotation> constraint()
+meth public abstract java.lang.String name()
+
+CLSS public abstract interface static !annotation javax.validation.OverridesAttribute$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.OverridesAttribute[] value()
+
+CLSS public abstract interface javax.validation.Path
+innr public abstract interface static Node
+intf java.lang.Iterable<javax.validation.Path$Node>
+
+CLSS public abstract interface static javax.validation.Path$Node
+meth public abstract boolean isInIterable()
+meth public abstract java.lang.Integer getIndex()
+meth public abstract java.lang.Object getKey()
+meth public abstract java.lang.String getName()
+
+CLSS public abstract interface javax.validation.Payload
+
+CLSS public abstract interface !annotation javax.validation.ReportAsSingleViolation
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE])
+intf java.lang.annotation.Annotation
+
+CLSS public abstract interface javax.validation.TraversableResolver
+meth public abstract boolean isCascadable(java.lang.Object,javax.validation.Path$Node,java.lang.Class<?>,javax.validation.Path,java.lang.annotation.ElementType)
+meth public abstract boolean isReachable(java.lang.Object,javax.validation.Path$Node,java.lang.Class<?>,javax.validation.Path,java.lang.annotation.ElementType)
+
+CLSS public javax.validation.UnexpectedTypeException
+cons public UnexpectedTypeException()
+cons public UnexpectedTypeException(java.lang.String)
+cons public UnexpectedTypeException(java.lang.String,java.lang.Throwable)
+cons public UnexpectedTypeException(java.lang.Throwable)
+supr javax.validation.ConstraintDeclarationException
+
+CLSS public abstract interface !annotation javax.validation.Valid
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+
+CLSS public javax.validation.Validation
+cons public Validation()
+meth public static <%0 extends javax.validation.Configuration<{%%0}>, %1 extends javax.validation.spi.ValidationProvider<{%%0}>> javax.validation.bootstrap.ProviderSpecificBootstrap<{%%0}> byProvider(java.lang.Class<{%%1}>)
+meth public static javax.validation.ValidatorFactory buildDefaultValidatorFactory()
+meth public static javax.validation.bootstrap.GenericBootstrap byDefaultProvider()
+supr java.lang.Object
+hcls DefaultValidationProviderResolver,GenericBootstrapImpl,GetClassLoader,ProviderSpecificBootstrapImpl
+
+CLSS public javax.validation.ValidationException
+cons public ValidationException()
+cons public ValidationException(java.lang.String)
+cons public ValidationException(java.lang.String,java.lang.Throwable)
+cons public ValidationException(java.lang.Throwable)
+supr java.lang.RuntimeException
+
+CLSS public abstract interface javax.validation.ValidationProviderResolver
+meth public abstract java.util.List<javax.validation.spi.ValidationProvider<?>> getValidationProviders()
+
+CLSS public abstract interface javax.validation.Validator
+meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<javax.validation.ConstraintViolation<{%%0}>> validate({%%0},java.lang.Class<?>[])
+meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<javax.validation.ConstraintViolation<{%%0}>> validateProperty({%%0},java.lang.String,java.lang.Class<?>[])
+meth public abstract !varargs <%0 extends java.lang.Object> java.util.Set<javax.validation.ConstraintViolation<{%%0}>> validateValue(java.lang.Class<{%%0}>,java.lang.String,java.lang.Object,java.lang.Class<?>[])
+meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.Class<{%%0}>)
+meth public abstract javax.validation.metadata.BeanDescriptor getConstraintsForClass(java.lang.Class<?>)
+
+CLSS public abstract interface javax.validation.ValidatorContext
+meth public abstract javax.validation.Validator getValidator()
+meth public abstract javax.validation.ValidatorContext constraintValidatorFactory(javax.validation.ConstraintValidatorFactory)
+meth public abstract javax.validation.ValidatorContext messageInterpolator(javax.validation.MessageInterpolator)
+meth public abstract javax.validation.ValidatorContext traversableResolver(javax.validation.TraversableResolver)
+
+CLSS public abstract interface javax.validation.ValidatorFactory
+meth public abstract <%0 extends java.lang.Object> {%%0} unwrap(java.lang.Class<{%%0}>)
+meth public abstract javax.validation.ConstraintValidatorFactory getConstraintValidatorFactory()
+meth public abstract javax.validation.MessageInterpolator getMessageInterpolator()
+meth public abstract javax.validation.TraversableResolver getTraversableResolver()
+meth public abstract javax.validation.Validator getValidator()
+meth public abstract javax.validation.ValidatorContext usingContext()
+
+CLSS public abstract interface javax.validation.bootstrap.GenericBootstrap
+meth public abstract javax.validation.Configuration<?> configure()
+meth public abstract javax.validation.bootstrap.GenericBootstrap providerResolver(javax.validation.ValidationProviderResolver)
+
+CLSS public abstract interface javax.validation.bootstrap.ProviderSpecificBootstrap<%0 extends javax.validation.Configuration<{javax.validation.bootstrap.ProviderSpecificBootstrap%0}>>
+meth public abstract javax.validation.bootstrap.ProviderSpecificBootstrap<{javax.validation.bootstrap.ProviderSpecificBootstrap%0}> providerResolver(javax.validation.ValidationProviderResolver)
+meth public abstract {javax.validation.bootstrap.ProviderSpecificBootstrap%0} configure()
+
+CLSS public abstract interface !annotation javax.validation.constraints.AssertFalse
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.AssertFalse$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.AssertFalse[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.AssertTrue
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.AssertTrue$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.AssertTrue[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.DecimalMax
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+meth public abstract java.lang.String value()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.DecimalMax$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.DecimalMax[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.DecimalMin
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+meth public abstract java.lang.String value()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.DecimalMin$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.DecimalMin[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Digits
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+meth public abstract int fraction()
+meth public abstract int integer()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Digits$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Digits[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Future
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Future$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Future[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Max
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+meth public abstract long value()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Max$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Max[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Min
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+meth public abstract long value()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Min$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Min[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.NotNull
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.NotNull$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.NotNull[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Null
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Null$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Null[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Past
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Past$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Past[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Pattern
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+innr public final static !enum Flag
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+meth public abstract !hasdefault javax.validation.constraints.Pattern$Flag[] flags()
+meth public abstract java.lang.String regexp()
+
+CLSS public final static !enum javax.validation.constraints.Pattern$Flag
+fld public final static javax.validation.constraints.Pattern$Flag CANON_EQ
+fld public final static javax.validation.constraints.Pattern$Flag CASE_INSENSITIVE
+fld public final static javax.validation.constraints.Pattern$Flag COMMENTS
+fld public final static javax.validation.constraints.Pattern$Flag DOTALL
+fld public final static javax.validation.constraints.Pattern$Flag MULTILINE
+fld public final static javax.validation.constraints.Pattern$Flag UNICODE_CASE
+fld public final static javax.validation.constraints.Pattern$Flag UNIX_LINES
+meth public final static javax.validation.constraints.Pattern$Flag[] values()
+meth public int getValue()
+meth public static javax.validation.constraints.Pattern$Flag valueOf(java.lang.String)
+supr java.lang.Enum<javax.validation.constraints.Pattern$Flag>
+hfds value
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Pattern$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Pattern[] value()
+
+CLSS public abstract interface !annotation javax.validation.constraints.Size
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+ anno 0 javax.validation.Constraint(java.lang.Class<? extends javax.validation.ConstraintValidator<?,?>>[] validatedBy=[])
+innr public abstract interface static !annotation List
+intf java.lang.annotation.Annotation
+meth public abstract !hasdefault int max()
+meth public abstract !hasdefault int min()
+meth public abstract !hasdefault java.lang.Class<? extends javax.validation.Payload>[] payload()
+meth public abstract !hasdefault java.lang.Class<?>[] groups()
+meth public abstract !hasdefault java.lang.String message()
+
+CLSS public abstract interface static !annotation javax.validation.constraints.Size$List
+ anno 0 java.lang.annotation.Documented()
+ anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME)
+ anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER])
+intf java.lang.annotation.Annotation
+meth public abstract javax.validation.constraints.Size[] value()
+
+CLSS public abstract interface javax.validation.groups.Default
+
+CLSS public abstract interface javax.validation.metadata.BeanDescriptor
+intf javax.validation.metadata.ElementDescriptor
+meth public abstract boolean isBeanConstrained()
+meth public abstract java.util.Set<javax.validation.metadata.PropertyDescriptor> getConstrainedProperties()
+meth public abstract javax.validation.metadata.PropertyDescriptor getConstraintsForProperty(java.lang.String)
+
+CLSS public abstract interface javax.validation.metadata.ConstraintDescriptor<%0 extends java.lang.annotation.Annotation>
+meth public abstract boolean isReportAsSingleViolation()
+meth public abstract java.util.List<java.lang.Class<? extends javax.validation.ConstraintValidator<{javax.validation.metadata.ConstraintDescriptor%0},?>>> getConstraintValidatorClasses()
+meth public abstract java.util.Map<java.lang.String,java.lang.Object> getAttributes()
+meth public abstract java.util.Set<java.lang.Class<? extends javax.validation.Payload>> getPayload()
+meth public abstract java.util.Set<java.lang.Class<?>> getGroups()
+meth public abstract java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> getComposingConstraints()
+meth public abstract {javax.validation.metadata.ConstraintDescriptor%0} getAnnotation()
+
+CLSS public abstract interface javax.validation.metadata.ElementDescriptor
+innr public abstract interface static ConstraintFinder
+meth public abstract boolean hasConstraints()
+meth public abstract java.lang.Class<?> getElementClass()
+meth public abstract java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> getConstraintDescriptors()
+meth public abstract javax.validation.metadata.ElementDescriptor$ConstraintFinder findConstraints()
+
+CLSS public abstract interface static javax.validation.metadata.ElementDescriptor$ConstraintFinder
+meth public abstract !varargs javax.validation.metadata.ElementDescriptor$ConstraintFinder declaredOn(java.lang.annotation.ElementType[])
+meth public abstract !varargs javax.validation.metadata.ElementDescriptor$ConstraintFinder unorderedAndMatchingGroups(java.lang.Class<?>[])
+meth public abstract boolean hasConstraints()
+meth public abstract java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> getConstraintDescriptors()
+meth public abstract javax.validation.metadata.ElementDescriptor$ConstraintFinder lookingAt(javax.validation.metadata.Scope)
+
+CLSS public abstract interface javax.validation.metadata.PropertyDescriptor
+intf javax.validation.metadata.ElementDescriptor
+meth public abstract boolean isCascaded()
+meth public abstract java.lang.String getPropertyName()
+
+CLSS public final !enum javax.validation.metadata.Scope
+fld public final static javax.validation.metadata.Scope HIERARCHY
+fld public final static javax.validation.metadata.Scope LOCAL_ELEMENT
+meth public final static javax.validation.metadata.Scope[] values()
+meth public static javax.validation.metadata.Scope valueOf(java.lang.String)
+supr java.lang.Enum<javax.validation.metadata.Scope>
+
+CLSS public abstract interface javax.validation.spi.BootstrapState
+meth public abstract javax.validation.ValidationProviderResolver getDefaultValidationProviderResolver()
+meth public abstract javax.validation.ValidationProviderResolver getValidationProviderResolver()
+
+CLSS public abstract interface javax.validation.spi.ConfigurationState
+meth public abstract boolean isIgnoreXmlConfiguration()
+meth public abstract java.util.Map<java.lang.String,java.lang.String> getProperties()
+meth public abstract java.util.Set<java.io.InputStream> getMappingStreams()
+meth public abstract javax.validation.ConstraintValidatorFactory getConstraintValidatorFactory()
+meth public abstract javax.validation.MessageInterpolator getMessageInterpolator()
+meth public abstract javax.validation.TraversableResolver getTraversableResolver()
+
+CLSS public abstract interface javax.validation.spi.ValidationProvider<%0 extends javax.validation.Configuration<{javax.validation.spi.ValidationProvider%0}>>
+meth public abstract javax.validation.Configuration<?> createGenericConfiguration(javax.validation.spi.BootstrapState)
+meth public abstract javax.validation.ValidatorFactory buildValidatorFactory(javax.validation.spi.ConfigurationState)
+meth public abstract {javax.validation.spi.ValidationProvider%0} createSpecializedConfiguration(javax.validation.spi.BootstrapState)
+
15 years
Hibernate SVN: r18022 - in beanvalidation/tck/trunk: src/main/assembly and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-11-23 06:19:49 -0500 (Mon, 23 Nov 2009)
New Revision: 18022
Added:
beanvalidation/tck/trunk/changelog.txt
Modified:
beanvalidation/tck/trunk/src/main/assembly/assembly.xml
Log:
BVTCK-3
Added: beanvalidation/tck/trunk/changelog.txt
===================================================================
--- beanvalidation/tck/trunk/changelog.txt (rev 0)
+++ beanvalidation/tck/trunk/changelog.txt 2009-11-23 11:19:49 UTC (rev 18022)
@@ -0,0 +1,19 @@
+Bean Validation TCK Changelog
+===============================
+
+See also http://opensource.atlassian.com/projects/hibernate/browse/BVTCK
+
+1.0.2.GA
+----------------------
+
+
+
+1.0.1.GA (28-10-2009)
+----------------------
+
+** Bug
+ * [BVTCK-1] - Make sure that validateValue and validateProperty tests only use single value properties
+
+** Task
+ * [BVTCK-2] - Move testcase for HV-253 into the TCK
+
Modified: beanvalidation/tck/trunk/src/main/assembly/assembly.xml
===================================================================
--- beanvalidation/tck/trunk/src/main/assembly/assembly.xml 2009-11-23 09:20:11 UTC (rev 18021)
+++ beanvalidation/tck/trunk/src/main/assembly/assembly.xml 2009-11-23 11:19:49 UTC (rev 18022)
@@ -70,8 +70,8 @@
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
- <include>readme.txt</include>
<include>apl.txt</include>
+ <include>changelog.txt</include>
</includes>
</fileSet>
</fileSets>
15 years
Hibernate SVN: r18021 - validator/trunk/hibernate-validator-annotation-processor.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-11-23 04:20:11 -0500 (Mon, 23 Nov 2009)
New Revision: 18021
Modified:
validator/trunk/hibernate-validator-annotation-processor/
Log:
added target to ignore directory
Property changes on: validator/trunk/hibernate-validator-annotation-processor
___________________________________________________________________
Name: svn:ignore
+ target
15 years
Hibernate SVN: r18020 - in core/trunk: testsuite/src/test/java/org/hibernate/test/collection/map and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-20 21:57:20 -0500 (Fri, 20 Nov 2009)
New Revision: 18020
Modified:
core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java
Log:
HHH-2584 - PersistentMap.remove() incorrect on uninitialized, non-extra-lazy map
Modified: core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java 2009-11-21 02:55:36 UTC (rev 18019)
+++ core/trunk/core/src/main/java/org/hibernate/collection/PersistentMap.java 2009-11-21 02:57:20 UTC (rev 18020)
@@ -199,17 +199,17 @@
public Object remove(Object key) {
if ( isPutQueueEnabled() ) {
Object old = readElementByIndex( key );
- queueOperation( new Remove( key, old ) );
- return old;
- }
- else {
- // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
- initialize( true );
- if ( map.containsKey( key ) ) {
- dirty();
+ if ( old != UNKNOWN ) {
+ queueOperation( new Remove( key, old ) );
+ return old;
}
- return map.remove( key );
}
+ // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
+ initialize( true );
+ if ( map.containsKey( key ) ) {
+ dirty();
+ }
+ return map.remove( key );
}
/**
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml 2009-11-21 02:55:36 UTC (rev 18019)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml 2009-11-21 02:57:20 UTC (rev 18020)
@@ -11,7 +11,7 @@
<map name="children" inverse="true" cascade="all">
<key column="PARENT" />
- <map-key type="string" />
+ <map-key type="string" formula="NAME"/>
<one-to-many class="Child" />
</map>
</class>
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java 2009-11-21 02:55:36 UTC (rev 18019)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java 2009-11-21 02:57:20 UTC (rev 18020)
@@ -10,7 +10,7 @@
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * todo: describe PersistentMapTest
+ * Test various situations using a {@link PersistentMap}.
*
* @author Steve Ebersole
*/
@@ -27,6 +27,7 @@
return new FunctionalTestClassTestSuite( PersistentMapTest.class );
}
+ @SuppressWarnings({ "unchecked" })
public void testWriteMethodDirtying() {
Parent parent = new Parent( "p1" );
Child child = new Child( "c1" );
@@ -38,7 +39,7 @@
session.beginTransaction();
session.save( parent );
session.flush();
- // at this point, the set on parent has now been replaced with a PersistentSet...
+ // at this point, the map on parent has now been replaced with a PersistentMap...
PersistentMap children = ( PersistentMap ) parent.getChildren();
Object old = children.put( child.getName(), child );
@@ -99,4 +100,38 @@
session.getTransaction().commit();
session.close();
}
+
+ public void testRemoveAgainstUninitializedMap() {
+ Parent parent = new Parent( "p1" );
+ Child child = new Child( "c1" );
+ parent.addChild( child );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.getTransaction().commit();
+ session.close();
+
+ // Now reload the parent and test removing the child
+ session = openSession();
+ session.beginTransaction();
+ parent = ( Parent ) session.get( Parent.class, parent.getName() );
+ Child child2 = ( Child ) parent.getChildren().remove( child.getName() );
+ child2.setParent( null );
+ assertNotNull( child2 );
+ assertTrue( parent.getChildren().isEmpty() );
+ session.getTransaction().commit();
+ session.close();
+
+ // Load the parent once again and make sure child is still gone
+ // then cleanup
+ session = openSession();
+ session.beginTransaction();
+ parent = ( Parent ) session.get( Parent.class, parent.getName() );
+ assertTrue( parent.getChildren().isEmpty() );
+ session.delete( child2 );
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
}
15 years
Hibernate SVN: r18019 - in core/branches/Branch_3_3: testsuite/src/test/java/org/hibernate/test/collection/map and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-20 21:55:36 -0500 (Fri, 20 Nov 2009)
New Revision: 18019
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/collection/PersistentMap.java
core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml
core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java
Log:
HHH-2584 - PersistentMap.remove() incorrect on uninitialized, non-extra-lazy map
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/collection/PersistentMap.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/collection/PersistentMap.java 2009-11-21 02:01:45 UTC (rev 18018)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/collection/PersistentMap.java 2009-11-21 02:55:36 UTC (rev 18019)
@@ -199,17 +199,17 @@
public Object remove(Object key) {
if ( isPutQueueEnabled() ) {
Object old = readElementByIndex( key );
- queueOperation( new Remove( key, old ) );
- return old;
- }
- else {
- // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
- initialize( true );
- if ( map.containsKey( key ) ) {
- dirty();
+ if ( old != UNKNOWN ) {
+ queueOperation( new Remove( key, old ) );
+ return old;
}
- return map.remove( key );
}
+ // TODO : safe to interpret "map.remove(key) == null" as non-dirty?
+ initialize( true );
+ if ( map.containsKey( key ) ) {
+ dirty();
+ }
+ return map.remove( key );
}
/**
Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml
===================================================================
--- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml 2009-11-21 02:01:45 UTC (rev 18018)
+++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/Mappings.hbm.xml 2009-11-21 02:55:36 UTC (rev 18019)
@@ -11,7 +11,7 @@
<map name="children" inverse="true" cascade="all">
<key column="PARENT" />
- <map-key type="string" />
+ <map-key type="string" formula="NAME"/>
<one-to-many class="Child" />
</map>
</class>
Modified: core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java
===================================================================
--- core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java 2009-11-21 02:01:45 UTC (rev 18018)
+++ core/branches/Branch_3_3/testsuite/src/test/java/org/hibernate/test/collection/map/PersistentMapTest.java 2009-11-21 02:55:36 UTC (rev 18019)
@@ -10,7 +10,7 @@
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
/**
- * todo: describe PersistentMapTest
+ * Test various situations using a {@link PersistentMap}.
*
* @author Steve Ebersole
*/
@@ -27,6 +27,7 @@
return new FunctionalTestClassTestSuite( PersistentMapTest.class );
}
+ @SuppressWarnings({ "unchecked" })
public void testWriteMethodDirtying() {
Parent parent = new Parent( "p1" );
Child child = new Child( "c1" );
@@ -38,7 +39,7 @@
session.beginTransaction();
session.save( parent );
session.flush();
- // at this point, the set on parent has now been replaced with a PersistentSet...
+ // at this point, the map on parent has now been replaced with a PersistentMap...
PersistentMap children = ( PersistentMap ) parent.getChildren();
Object old = children.put( child.getName(), child );
@@ -99,4 +100,38 @@
session.getTransaction().commit();
session.close();
}
+
+ public void testRemoveAgainstUninitializedMap() {
+ Parent parent = new Parent( "p1" );
+ Child child = new Child( "c1" );
+ parent.addChild( child );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.getTransaction().commit();
+ session.close();
+
+ // Now reload the parent and test removing the child
+ session = openSession();
+ session.beginTransaction();
+ parent = ( Parent ) session.get( Parent.class, parent.getName() );
+ Child child2 = ( Child ) parent.getChildren().remove( child.getName() );
+ child2.setParent( null );
+ assertNotNull( child2 );
+ assertTrue( parent.getChildren().isEmpty() );
+ session.getTransaction().commit();
+ session.close();
+
+ // Load the parent once again and make sure child is still gone
+ // then cleanup
+ session = openSession();
+ session.beginTransaction();
+ parent = ( Parent ) session.get( Parent.class, parent.getName() );
+ assertTrue( parent.getChildren().isEmpty() );
+ session.delete( child2 );
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
}
15 years
Hibernate SVN: r18018 - core/trunk/core/src/main/java/org/hibernate/loader/custom/sql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-20 21:01:45 -0500 (Fri, 20 Nov 2009)
New Revision: 18018
Modified:
core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java
core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
Log:
HHH-2576 - Allow native-sql to have placeholders for default schema and catalog
Modified: core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java 2009-11-21 02:00:30 UTC (rev 18017)
+++ core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java 2009-11-21 02:01:45 UTC (rev 18018)
@@ -129,7 +129,7 @@
//
// String[] suffixes = BasicLoader.generateSuffixes(entityPersisters.length);
- SQLQueryParser parser = new SQLQueryParser( sqlQuery, new ParserContext( aliasContext ) );
+ SQLQueryParser parser = new SQLQueryParser( sqlQuery, new ParserContext( aliasContext ), factory );
this.sql = parser.process();
this.namedParameterBindPoints.putAll( parser.getNamedParameters() );
Modified: core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java 2009-11-21 02:00:30 UTC (rev 18017)
+++ core/trunk/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java 2009-11-21 02:01:45 UTC (rev 18018)
@@ -25,6 +25,7 @@
package org.hibernate.loader.custom.sql;
import org.hibernate.QueryException;
+import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.query.ParameterParser;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.SQLLoadable;
@@ -38,9 +39,15 @@
* @author Gavin King
* @author Max Andersen
* @author Steve Ebersole
+ * @author Paul Benedict
*/
public class SQLQueryParser {
+ private static final String HIBERNATE_PLACEHOLDER_PREFIX = "h-";
+ private static final String DOMAIN_PLACEHOLDER = "h-domain";
+ private static final String CATALOG_PLACEHOLDER = "h-catalog";
+ private static final String SCHEMA_PLACEHOLDER = "h-schema";
+ private final SessionFactoryImplementor factory;
private final String originalQueryString;
private final ParserContext context;
@@ -57,9 +64,10 @@
Map getPropertyResultsMapByAlias(String alias);
}
- public SQLQueryParser(String queryString, ParserContext context) {
+ public SQLQueryParser(String queryString, ParserContext context, SessionFactoryImplementor factory) {
this.originalQueryString = queryString;
this.context = context;
+ this.factory = factory;
}
public Map getNamedParameters() {
@@ -71,7 +79,9 @@
}
public String process() {
- return substituteParams( substituteBrackets( originalQueryString ) );
+ String processedSql = substituteBrackets( originalQueryString );
+ processedSql = substituteParams( processedSql );
+ return processedSql;
}
// TODO: should "record" how many properties we have reffered to - and if we
@@ -97,41 +107,75 @@
throw new QueryException( "Unmatched braces for alias path", sqlQuery );
}
- String aliasPath = sqlQuery.substring( left + 1, right );
- int firstDot = aliasPath.indexOf( '.' );
- if ( firstDot == -1 ) {
- if ( context.isEntityAlias( aliasPath ) ) {
- // it is a simple table alias {foo}
- result.append( aliasPath );
- aliasesFound++;
+ final String aliasPath = sqlQuery.substring( left + 1, right );
+ boolean isPlaceholder = aliasPath.startsWith( HIBERNATE_PLACEHOLDER_PREFIX );
+
+ if ( isPlaceholder ) {
+ // Domain replacement
+ if ( DOMAIN_PLACEHOLDER.equals( aliasPath ) ) {
+ final String catalogName = factory.getSettings().getDefaultCatalogName();
+ if ( catalogName != null ) {
+ result.append( catalogName );
+ result.append( "." );
+ }
+ final String schemaName = factory.getSettings().getDefaultSchemaName();
+ if ( schemaName != null ) {
+ result.append( schemaName );
+ result.append( "." );
+ }
+ }
+ // Schema replacement
+ else if ( SCHEMA_PLACEHOLDER.equals( aliasPath ) ) {
+ final String schemaName = factory.getSettings().getDefaultSchemaName();
+ if ( schemaName != null ) {
+ result.append(schemaName);
+ result.append(".");
+ }
}
+ // Catalog replacement
+ else if ( CATALOG_PLACEHOLDER.equals( aliasPath ) ) {
+ final String catalogName = factory.getSettings().getDefaultCatalogName();
+ if ( catalogName != null ) {
+ result.append( catalogName );
+ result.append( "." );
+ }
+ }
else {
- // passing through anything we do not know : to support jdbc escape sequences HB-898
- result.append( '{' ).append(aliasPath).append( '}' );
+ throw new QueryException( "Unknown placeholder ", aliasPath );
}
}
else {
- String aliasName = aliasPath.substring(0, firstDot);
- boolean isCollection = context.isCollectionAlias( aliasName );
- boolean isEntity = context.isEntityAlias( aliasName );
-
- if ( isCollection ) {
- // The current alias is referencing the collection to be eagerly fetched
- String propertyName = aliasPath.substring( firstDot + 1 );
- result.append( resolveCollectionProperties( aliasName, propertyName ) );
- aliasesFound++;
- }
- else if ( isEntity ) {
- // it is a property reference {foo.bar}
- String propertyName = aliasPath.substring( firstDot + 1 );
- result.append( resolveProperties( aliasName, propertyName ) );
- aliasesFound++;
+ int firstDot = aliasPath.indexOf( '.' );
+ if ( firstDot == -1 ) {
+ if ( context.isEntityAlias( aliasPath ) ) {
+ // it is a simple table alias {foo}
+ result.append( aliasPath );
+ aliasesFound++;
+ }
+ else {
+ // passing through anything we do not know : to support jdbc escape sequences HB-898
+ result.append( '{' ).append(aliasPath).append( '}' );
+ }
}
else {
- // passing through anything we do not know : to support jdbc escape sequences HB-898
- result.append( '{' ).append(aliasPath).append( '}' );
+ final String aliasName = aliasPath.substring( 0, firstDot );
+ if ( context.isCollectionAlias( aliasName ) ) {
+ // The current alias is referencing the collection to be eagerly fetched
+ String propertyName = aliasPath.substring( firstDot + 1 );
+ result.append( resolveCollectionProperties( aliasName, propertyName ) );
+ aliasesFound++;
+ }
+ else if ( context.isEntityAlias( aliasName ) ) {
+ // it is a property reference {foo.bar}
+ String propertyName = aliasPath.substring( firstDot + 1 );
+ result.append( resolveProperties( aliasName, propertyName ) );
+ aliasesFound++;
+ }
+ else {
+ // passing through anything we do not know : to support jdbc escape sequences HB-898
+ result.append( '{' ).append(aliasPath).append( '}' );
+ }
}
-
}
}
15 years
Hibernate SVN: r18017 - core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-11-20 21:00:30 -0500 (Fri, 20 Nov 2009)
New Revision: 18017
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java
core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
Log:
HHH-2576 - Allow native-sql to have placeholders for default schema and catalog
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java 2009-11-20 14:51:13 UTC (rev 18016)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLCustomQuery.java 2009-11-21 02:00:30 UTC (rev 18017)
@@ -129,7 +129,7 @@
//
// String[] suffixes = BasicLoader.generateSuffixes(entityPersisters.length);
- SQLQueryParser parser = new SQLQueryParser( sqlQuery, new ParserContext( aliasContext ) );
+ SQLQueryParser parser = new SQLQueryParser( sqlQuery, new ParserContext( aliasContext ), factory );
this.sql = parser.process();
this.namedParameterBindPoints.putAll( parser.getNamedParameters() );
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java 2009-11-20 14:51:13 UTC (rev 18016)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java 2009-11-21 02:00:30 UTC (rev 18017)
@@ -25,6 +25,7 @@
package org.hibernate.loader.custom.sql;
import org.hibernate.QueryException;
+import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.query.ParameterParser;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.SQLLoadable;
@@ -38,9 +39,15 @@
* @author Gavin King
* @author Max Andersen
* @author Steve Ebersole
+ * @author Paul Benedict
*/
public class SQLQueryParser {
+ private static final String HIBERNATE_PLACEHOLDER_PREFIX = "h-";
+ private static final String DOMAIN_PLACEHOLDER = "h-domain";
+ private static final String CATALOG_PLACEHOLDER = "h-catalog";
+ private static final String SCHEMA_PLACEHOLDER = "h-schema";
+ private final SessionFactoryImplementor factory;
private final String originalQueryString;
private final ParserContext context;
@@ -57,9 +64,10 @@
Map getPropertyResultsMapByAlias(String alias);
}
- public SQLQueryParser(String queryString, ParserContext context) {
+ public SQLQueryParser(String queryString, ParserContext context, SessionFactoryImplementor factory) {
this.originalQueryString = queryString;
this.context = context;
+ this.factory = factory;
}
public Map getNamedParameters() {
@@ -71,7 +79,9 @@
}
public String process() {
- return substituteParams( substituteBrackets( originalQueryString ) );
+ String processedSql = substituteBrackets( originalQueryString );
+ processedSql = substituteParams( processedSql );
+ return processedSql;
}
// TODO: should "record" how many properties we have reffered to - and if we
@@ -97,41 +107,75 @@
throw new QueryException( "Unmatched braces for alias path", sqlQuery );
}
- String aliasPath = sqlQuery.substring( left + 1, right );
- int firstDot = aliasPath.indexOf( '.' );
- if ( firstDot == -1 ) {
- if ( context.isEntityAlias( aliasPath ) ) {
- // it is a simple table alias {foo}
- result.append( aliasPath );
- aliasesFound++;
+ final String aliasPath = sqlQuery.substring( left + 1, right );
+ boolean isPlaceholder = aliasPath.startsWith( HIBERNATE_PLACEHOLDER_PREFIX );
+
+ if ( isPlaceholder ) {
+ // Domain replacement
+ if ( DOMAIN_PLACEHOLDER.equals( aliasPath ) ) {
+ final String catalogName = factory.getSettings().getDefaultCatalogName();
+ if ( catalogName != null ) {
+ result.append( catalogName );
+ result.append( "." );
+ }
+ final String schemaName = factory.getSettings().getDefaultSchemaName();
+ if ( schemaName != null ) {
+ result.append( schemaName );
+ result.append( "." );
+ }
+ }
+ // Schema replacement
+ else if ( SCHEMA_PLACEHOLDER.equals( aliasPath ) ) {
+ final String schemaName = factory.getSettings().getDefaultSchemaName();
+ if ( schemaName != null ) {
+ result.append(schemaName);
+ result.append(".");
+ }
}
+ // Catalog replacement
+ else if ( CATALOG_PLACEHOLDER.equals( aliasPath ) ) {
+ final String catalogName = factory.getSettings().getDefaultCatalogName();
+ if ( catalogName != null ) {
+ result.append( catalogName );
+ result.append( "." );
+ }
+ }
else {
- // passing through anything we do not know : to support jdbc escape sequences HB-898
- result.append( '{' ).append(aliasPath).append( '}' );
+ throw new QueryException( "Unknown placeholder ", aliasPath );
}
}
else {
- String aliasName = aliasPath.substring(0, firstDot);
- boolean isCollection = context.isCollectionAlias( aliasName );
- boolean isEntity = context.isEntityAlias( aliasName );
-
- if ( isCollection ) {
- // The current alias is referencing the collection to be eagerly fetched
- String propertyName = aliasPath.substring( firstDot + 1 );
- result.append( resolveCollectionProperties( aliasName, propertyName ) );
- aliasesFound++;
- }
- else if ( isEntity ) {
- // it is a property reference {foo.bar}
- String propertyName = aliasPath.substring( firstDot + 1 );
- result.append( resolveProperties( aliasName, propertyName ) );
- aliasesFound++;
+ int firstDot = aliasPath.indexOf( '.' );
+ if ( firstDot == -1 ) {
+ if ( context.isEntityAlias( aliasPath ) ) {
+ // it is a simple table alias {foo}
+ result.append( aliasPath );
+ aliasesFound++;
+ }
+ else {
+ // passing through anything we do not know : to support jdbc escape sequences HB-898
+ result.append( '{' ).append(aliasPath).append( '}' );
+ }
}
else {
- // passing through anything we do not know : to support jdbc escape sequences HB-898
- result.append( '{' ).append(aliasPath).append( '}' );
+ final String aliasName = aliasPath.substring( 0, firstDot );
+ if ( context.isCollectionAlias( aliasName ) ) {
+ // The current alias is referencing the collection to be eagerly fetched
+ String propertyName = aliasPath.substring( firstDot + 1 );
+ result.append( resolveCollectionProperties( aliasName, propertyName ) );
+ aliasesFound++;
+ }
+ else if ( context.isEntityAlias( aliasName ) ) {
+ // it is a property reference {foo.bar}
+ String propertyName = aliasPath.substring( firstDot + 1 );
+ result.append( resolveProperties( aliasName, propertyName ) );
+ aliasesFound++;
+ }
+ else {
+ // passing through anything we do not know : to support jdbc escape sequences HB-898
+ result.append( '{' ).append(aliasPath).append( '}' );
+ }
}
-
}
}
15 years
Hibernate SVN: r18016 - in core/trunk: core/src/main/java/org/hibernate/engine and 9 other directories.
by hibernate-commits@lists.jboss.org
Author: smarlow(a)redhat.com
Date: 2009-11-20 09:51:13 -0500 (Fri, 20 Nov 2009)
New Revision: 18016
Added:
core/trunk/core/src/main/java/org/hibernate/LockRequest.java
Modified:
core/trunk/core/src/main/java/org/hibernate/Session.java
core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java
core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java
core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java
core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java
core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java
core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java
core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
core/trunk/core/src/main/java/org/hibernate/loader/entity/AbstractEntityLoader.java
core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java
core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java
core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java
core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java
Log:
HHH-4546 add JPA 2.0 locking. Still need more LockRequest support in AbstractEntityPersister.getAppropriateLoader(), may need to refactor.
Added: core/trunk/core/src/main/java/org/hibernate/LockRequest.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/LockRequest.java (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/LockRequest.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -0,0 +1,115 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Contains locking details (LockMode, Timeout and Scope).
+ *
+ * @author Scott Marlow
+ */
+public class LockRequest
+{
+
+ public static final int NO_WAIT = 0;
+ public static final int WAIT_FOREVER = -1;
+
+ private LockMode lockMode = LockMode.NONE;
+
+ private int timeout = WAIT_FOREVER; // timeout in milliseconds, 0 = no wait, -1 = wait indefinitely
+
+ private boolean scope=false;// if true, cascade (pessimistic only) lock to collections and relationships
+ // owned by the entity.
+
+ public LockRequest() {
+
+ }
+
+ public LockRequest( LockMode lockMode, int timeout, boolean scope ) {
+ this.lockMode = lockMode;
+ this.timeout = timeout;
+ this.scope = scope;
+ }
+
+ /**
+ * Get the lock mode.
+ * @return the lock mode.
+ */
+ public LockMode getLockMode() {
+ return lockMode;
+ }
+
+ /**
+ * Specify the LockMode to be used. The default is LockMode.none.
+ *
+ * @param lockMode
+ * @return this LockRequest instance for operation chaining.
+ */
+ public LockRequest setLockMode(LockMode lockMode) {
+ this.lockMode = lockMode;
+ return this;
+ }
+
+ /**
+ * Get the timeout setting.
+ *
+ * @return timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
+ */
+ public int getTimeOut() {
+ return timeout;
+ }
+
+ /**
+ * Specify the pessimistic lock timeout (check if your dialect supports this option).
+ * The default pessimistic lock behavior is to wait forever for the lock.
+ *
+ * @param timeout is time in milliseconds to wait for lock. -1 means wait forever and 0 means no wait.
+ * @return this LockRequest instance for operation chaining.
+ */
+ public LockRequest setTimeOut(int timeout) {
+ this.timeout = timeout;
+ return this;
+ }
+
+ /**
+ * Check if locking is cascaded to owned collections and relationships.
+ * @return true if locking will be extended to owned collections and relationships.
+ */
+ public boolean getScope() {
+ return scope;
+ }
+
+ /**
+ * Specify if LockMode should be cascaded to owned collections and relationships.
+ * The association must be mapped with <tt>cascade="lock" for scope=true to work.
+ *
+ * @param scope
+ * @return
+ */
+ public LockRequest setScope(boolean scope) {
+ this.scope = scope;
+ return this;
+ }
+
+}
Modified: core/trunk/core/src/main/java/org/hibernate/Session.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Session.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/Session.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -270,6 +270,7 @@
* @param lockMode the lock level
* @return the persistent instance or proxy
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException;
@@ -277,16 +278,41 @@
* Return the persistent instance of the given entity class with the given identifier,
* obtaining the specified lock mode, assuming the instance exists.
*
+ * @param theClass a persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @param lockRequest contains the lock level
+ * @return the persistent instance or proxy
+ * @throws HibernateException
+ */
+ public Object load(Class theClass, Serializable id, LockRequest lockRequest) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * obtaining the specified lock mode, assuming the instance exists.
+ *
* @param entityName a persistent class
* @param id a valid identifier of an existing persistent instance of the class
* @param lockMode the lock level
* @return the persistent instance or proxy
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
/**
* Return the persistent instance of the given entity class with the given identifier,
+ * obtaining the specified lock mode, assuming the instance exists.
+ *
+ * @param entityName a persistent class
+ * @param id a valid identifier of an existing persistent instance of the class
+ * @param lockRequest contains the lock level
+ * @return the persistent instance or proxy
+ * @throws HibernateException
+ */
+ public Object load(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException;
+
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
* assuming that the instance exists. This method might return a proxied instance that
* is initialized on-demand, when a non-identifier method is accessed.
* <br><br>
@@ -500,30 +526,69 @@
/**
* Obtain the specified lock level upon the given object. This may be used to
* perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
- * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
+ * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
* with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
* instances if the association is mapped with <tt>cascade="lock"</tt>.
*
* @param object a persistent or transient instance
* @param lockMode the lock level
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public void lock(Object object, LockMode lockMode) throws HibernateException;
/**
* Obtain the specified lock level upon the given object. This may be used to
- * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic
- * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance
+ * perform a version check (<tt>LockMode.OPTIMISTIC</tt>), to upgrade to a pessimistic
+ * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
* with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="lock" and lockRequest.getScope() == true</tt>.
+ *
+ * @param object a persistent or transient instance
+ * @param lockRequest contains the lock level
+ * @throws HibernateException
+ */
+ public void lock(Object object, LockRequest lockRequest) throws HibernateException;
+
+ /**
+ * Obtain the specified lock level upon the given object. This may be used to
+ * perform a version check (<tt>LockMode.OPTIMISTIC</tt>), to upgrade to a pessimistic
+ * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
* instances if the association is mapped with <tt>cascade="lock"</tt>.
*
* @param object a persistent or transient instance
* @param lockMode the lock level
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException;
/**
+ * Obtain the specified lock level upon the given object. This may be used to
+ * perform a version check (<tt>LockMode.OPTIMISTIC</tt>), to upgrade to a pessimistic
+ * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
+ * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
+ * instances if the association is mapped with <tt>cascade="lock" and lockRequest.getScope() == true.</tt>.
+ *
+ * @param object a persistent or transient instance
+ * @param lockRequest contains the lock level
+ * @throws HibernateException
+ */
+ public void lock(String entityName, Object object, LockRequest lockRequest) throws HibernateException;
+
+ /**
+ * Build a lockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.
+ * timeout and scope is ignored for optimistic locking.
+ *
+ * Use: LockRequest lr = session.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(1000 * 60);
+ * session.lock(entity, lr);
+ *
+ * @throws HibernateException
+ */
+ LockRequest buildLockRequest();
+
+ /**
* Re-read the state of the given instance from the underlying database. It is
* inadvisable to use this to implement long-running sessions that span many
* business tasks. This method is, however, useful in certain special circumstances.
@@ -548,10 +613,23 @@
* @param object a persistent or detached instance
* @param lockMode the lock mode to use
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public void refresh(Object object, LockMode lockMode) throws HibernateException;
/**
+ * Re-read the state of the given instance from the underlying database, with
+ * the given <tt>LockMode</tt>. It is inadvisable to use this to implement
+ * long-running sessions that span many business tasks. This method is, however,
+ * useful in certain special circumstances.
+ *
+ * @param object a persistent or detached instance
+ * @param lockRequest contains the lock mode to use
+ * @throws HibernateException
+ */
+ public void refresh(Object object, LockRequest lockRequest) throws HibernateException;
+
+ /**
* Determine the current lock mode of the given object.
*
* @param object a persistent instance
@@ -688,10 +766,25 @@
* @param lockMode the lock mode
* @return a persistent instance or null
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException;
/**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * or null if there is no such persistent instance. (If the instance is already associated
+ * with the session, return that instance. This method never returns an uninitialized instance.)
+ * Obtain the specified lock mode if the instance exists.
+ *
+ * @param clazz a persistent class
+ * @param id an identifier
+ * @param lockRequest the lock mode
+ * @return a persistent instance or null
+ * @throws HibernateException
+ */
+ public Object get(Class clazz, Serializable id, LockRequest lockRequest) throws HibernateException;
+
+ /**
* Return the persistent instance of the given named entity with the given identifier,
* or null if there is no such persistent instance. (If the instance is already associated
* with the session, return that instance. This method never returns an uninitialized instance.)
@@ -714,9 +807,24 @@
* @param lockMode the lock mode
* @return a persistent instance or null
* @throws HibernateException
+ * @deprecated LockMode parameter should be replaced with a LockRequest
*/
public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
+ /**
+ * Return the persistent instance of the given entity class with the given identifier,
+ * or null if there is no such persistent instance. (If the instance is already associated
+ * with the session, return that instance. This method never returns an uninitialized instance.)
+ * Obtain the specified lock mode if the instance exists.
+ *
+ * @param entityName the entity name
+ * @param id an identifier
+ * @param lockRequest contains the lock mode
+ * @return a persistent instance or null
+ * @throws HibernateException
+ */
+ public Object get(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException;
+
/**
* Return the entity name for a persistent entity
Modified: core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -34,6 +34,7 @@
import org.hibernate.LockMode;
import org.hibernate.ReplicationMode;
import org.hibernate.TransientObjectException;
+import org.hibernate.LockRequest;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.collection.PersistentCollection;
@@ -165,7 +166,17 @@
if ( log.isTraceEnabled() ) {
log.trace( "cascading to lock: " + entityName );
}
- session.lock( entityName, child, LockMode.NONE/*(LockMode) anything*/ );
+ LockMode lockMode = LockMode.NONE;
+ LockRequest lr = new LockRequest();
+ if ( anything instanceof LockRequest ) {
+ LockRequest lockRequest = (LockRequest)anything;
+ lr.setTimeOut(lockRequest.getTimeOut());
+ lr.setScope( lockRequest.getScope());
+ if ( lockRequest.getScope() == true ) // cascade specified lockMode
+ lockMode = lockRequest.getLockMode();
+ }
+ lr.setLockMode(lockMode);
+ session.lock( entityName, child, lr);
}
public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
// lock doesn't cascade to uninitialized collections
Modified: core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -27,6 +27,7 @@
import java.io.Serializable;
import org.hibernate.LockMode;
+import org.hibernate.LockRequest;
/**
* Defines an event class for the loading of an entity.
@@ -40,20 +41,24 @@
private Serializable entityId;
private String entityClassName;
private Object instanceToLoad;
- private LockMode lockMode;
+ private LockRequest lockRequest;
private boolean isAssociationFetch;
private Object result;
public LoadEvent(Serializable entityId, Object instanceToLoad, EventSource source) {
- this(entityId, null, instanceToLoad, null, false, source);
+ this(entityId, null, instanceToLoad, new LockRequest(), false, source);
}
public LoadEvent(Serializable entityId, String entityClassName, LockMode lockMode, EventSource source) {
this(entityId, entityClassName, null, lockMode, false, source);
}
-
+
+ public LoadEvent(Serializable entityId, String entityClassName, LockRequest lockRequest, EventSource source) {
+ this(entityId, entityClassName, null, lockRequest, false, source);
+ }
+
public LoadEvent(Serializable entityId, String entityClassName, boolean isAssociationFetch, EventSource source) {
- this(entityId, entityClassName, null, null, isAssociationFetch, source);
+ this(entityId, entityClassName, null, new LockRequest(), isAssociationFetch, source);
}
public boolean isAssociationFetch() {
@@ -67,24 +72,34 @@
LockMode lockMode,
boolean isAssociationFetch,
EventSource source) {
+ this(entityId, entityClassName, instanceToLoad, new LockRequest().setLockMode(lockMode), isAssociationFetch, source );
+ }
+ private LoadEvent(
+ Serializable entityId,
+ String entityClassName,
+ Object instanceToLoad,
+ LockRequest lockRequest,
+ boolean isAssociationFetch,
+ EventSource source) {
+
super(source);
if ( entityId == null ) {
throw new IllegalArgumentException("id to load is required for loading");
}
- if ( lockMode == LockMode.WRITE ) {
+ if ( lockRequest.getLockMode() == LockMode.WRITE ) {
throw new IllegalArgumentException("Invalid lock mode for loading");
}
- else if ( lockMode == null ) {
- lockMode = DEFAULT_LOCK_MODE;
+ else if ( lockRequest.getLockMode() == null ) {
+ lockRequest.setLockMode(DEFAULT_LOCK_MODE);
}
this.entityId = entityId;
this.entityClassName = entityClassName;
this.instanceToLoad = instanceToLoad;
- this.lockMode = lockMode;
+ this.lockRequest = lockRequest;
this.isAssociationFetch = isAssociationFetch;
}
@@ -112,14 +127,34 @@
this.instanceToLoad = instanceToLoad;
}
+ public LockRequest getLockRequest() {
+ return lockRequest;
+ }
+
public LockMode getLockMode() {
- return lockMode;
+ return lockRequest.getLockMode();
}
public void setLockMode(LockMode lockMode) {
- this.lockMode = lockMode;
+ this.lockRequest.setLockMode(lockMode);
}
+ public void setLockTimeout(int timeout) {
+ this.lockRequest.setTimeOut(timeout);
+ }
+
+ public int getLockTimeout() {
+ return this.lockRequest.getTimeOut();
+ }
+
+ public void setLockScope(boolean cascade) {
+ this.lockRequest.setScope(cascade);
+ }
+
+ public boolean getLockScope() {
+ return this.lockRequest.getScope();
+ }
+
public Object getResult() {
return result;
}
Modified: core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -25,6 +25,7 @@
package org.hibernate.event;
import org.hibernate.LockMode;
+import org.hibernate.LockRequest;
/**
* Defines an event class for the locking of an entity.
@@ -34,7 +35,7 @@
public class LockEvent extends AbstractEvent {
private Object object;
- private LockMode lockMode;
+ private LockRequest lockRequest;
private String entityName;
public LockEvent(String entityName, Object original, LockMode lockMode, EventSource source) {
@@ -42,12 +43,23 @@
this.entityName = entityName;
}
+ public LockEvent(String entityName, Object original, LockRequest lockRequest, EventSource source) {
+ this(original, lockRequest, source);
+ this.entityName = entityName;
+ }
+
public LockEvent(Object object, LockMode lockMode, EventSource source) {
super(source);
this.object = object;
- this.lockMode = lockMode;
+ this.lockRequest = new LockRequest().setLockMode(lockMode);
}
+ public LockEvent(Object object, LockRequest lockRequest, EventSource source) {
+ super(source);
+ this.object = object;
+ this.lockRequest = lockRequest;
+ }
+
public Object getObject() {
return object;
}
@@ -56,14 +68,34 @@
this.object = object;
}
+ public LockRequest getLockRequest() {
+ return lockRequest;
+ }
+
public LockMode getLockMode() {
- return lockMode;
+ return lockRequest.getLockMode();
}
public void setLockMode(LockMode lockMode) {
- this.lockMode = lockMode;
+ this.lockRequest.setLockMode(lockMode);
}
+ public void setLockTimeout(int timeout) {
+ this.lockRequest.setTimeOut(timeout);
+ }
+
+ public int getLockTimeout() {
+ return this.lockRequest.getTimeOut();
+ }
+
+ public void setLockScope(boolean cascade) {
+ this.lockRequest.setScope(cascade);
+ }
+
+ public boolean getLockScope() {
+ return this.lockRequest.getScope();
+ }
+
public String getEntityName() {
return entityName;
}
Modified: core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -25,6 +25,7 @@
package org.hibernate.event;
import org.hibernate.LockMode;
+import org.hibernate.LockRequest;
/**
* Defines an event class for the refreshing of an object.
@@ -34,7 +35,7 @@
public class RefreshEvent extends AbstractEvent {
private Object object;
- private LockMode lockMode = LockMode.READ;
+ private LockRequest lockRequest = new LockRequest().setLockMode(LockMode.READ);
public RefreshEvent(Object object, EventSource source) {
super(source);
@@ -49,14 +50,34 @@
if (lockMode == null) {
throw new IllegalArgumentException("Attempt to generate refresh event with null lock mode");
}
- this.lockMode = lockMode;
+ this.lockRequest.setLockMode(lockMode);
}
+ public RefreshEvent(Object object, LockRequest lockRequest, EventSource source) {
+ this(object, source);
+ if (lockRequest == null) {
+ throw new IllegalArgumentException("Attempt to generate refresh event with null lock request");
+ }
+ this.lockRequest = lockRequest;
+ }
+
public Object getObject() {
return object;
}
+ public LockRequest getLockRequest() {
+ return lockRequest;
+ }
+
public LockMode getLockMode() {
- return lockMode;
+ return lockRequest.getLockMode();
}
+
+ public int getLockTimeout() {
+ return this.lockRequest.getTimeOut();
+ }
+
+ public boolean getLockScope() {
+ return this.lockRequest.getScope();
+ }
}
Modified: core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -30,6 +30,7 @@
import org.hibernate.LockMode;
import org.hibernate.ObjectDeletedException;
import org.hibernate.OptimisticLockException;
+import org.hibernate.LockRequest;
import org.hibernate.event.EventSource;
import org.hibernate.action.EntityIncrementVersionProcess;
import org.hibernate.action.EntityVerifyVersionProcess;
@@ -55,11 +56,12 @@
*
* @param object The entity for which to upgrade the lock.
* @param entry The entity's EntityEntry instance.
- * @param requestedLockMode The lock mode being requested for locking.
+ * @param lockRequest contains the requested lock mode.
* @param source The session which is the source of the event being processed.
*/
- protected void upgradeLock(Object object, EntityEntry entry, LockMode requestedLockMode, EventSource source) {
+ protected void upgradeLock(Object object, EntityEntry entry, LockRequest lockRequest, EventSource source) {
+ LockMode requestedLockMode = lockRequest.getLockMode();
if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
// The user requested a "greater" (i.e. more restrictive) form of
// pessimistic lock
Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -485,7 +485,7 @@
return INCONSISTENT_RTN_CLASS_MARKER;
}
}
- upgradeLock( old, oldEntry, event.getLockMode(), event.getSession() );
+ upgradeLock( old, oldEntry, event.getLockRequest(), event.getSession() );
}
return old;
Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -80,11 +80,10 @@
}
entry = reassociate(event, entity, id, persister);
- // TODO: make cascadeOnLock optional based on SCOPE
cascadeOnLock(event, persister, entity);
}
- upgradeLock( entity, entry, event.getLockMode(), event.getSession() );
+ upgradeLock( entity, entry, event.getLockRequest(), event.getSession() );
}
private void cascadeOnLock(LockEvent event, EntityPersister persister, Object entity) {
@@ -92,7 +91,7 @@
source.getPersistenceContext().incrementCascadeLevel();
try {
new Cascade(CascadingAction.LOCK, Cascade.AFTER_LOCK, source)
- .cascade( persister, entity, event.getLockMode() );
+ .cascade( persister, entity, event.getLockRequest() );
}
finally {
source.getPersistenceContext().decrementCascadeLevel();
Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -142,7 +142,7 @@
String previousFetchProfile = source.getFetchProfile();
source.setFetchProfile("refresh");
- Object result = persister.load( id, object, event.getLockMode(), source );
+ Object result = persister.load( id, object, event.getLockRequest(), source );
source.setFetchProfile(previousFetchProfile);
UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() );
Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -69,6 +69,7 @@
import org.hibernate.UnresolvableObjectException;
import org.hibernate.UnknownProfileException;
import org.hibernate.EntityNameResolver;
+import org.hibernate.LockRequest;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.ActionQueue;
import org.hibernate.engine.CollectionEntry;
@@ -134,7 +135,6 @@
import org.hibernate.util.ArrayHelper;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
-import org.hibernate.util.SerializationHelper;
/**
@@ -742,10 +742,23 @@
fireLock( new LockEvent(entityName, object, lockMode, this) );
}
+ public void lock(String entityName, Object object, LockRequest lockRequest) throws HibernateException {
+ fireLock( new LockEvent(entityName, object, lockRequest, this) );
+ }
+
+ public LockRequest buildLockRequest() {
+ return new LockRequest();
+ }
+
public void lock(Object object, LockMode lockMode) throws HibernateException {
fireLock( new LockEvent(object, lockMode, this) );
}
+
+ public void lock(Object object, LockRequest lockRequest) throws HibernateException {
+ fireLock( new LockEvent(object, lockRequest, this) );
+ }
+
private void fireLock(LockEvent lockEvent) {
errorIfClosed();
checkTransactionSynchStatus();
@@ -1024,22 +1037,42 @@
return load( entityClass.getName(), id, lockMode );
}
+ public Object load(Class entityClass, Serializable id, LockRequest lockRequest) throws HibernateException {
+ return load( entityClass.getName(), id, lockRequest );
+ }
+
public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
LoadEvent event = new LoadEvent(id, entityName, lockMode, this);
fireLoad( event, LoadEventListener.LOAD );
return event.getResult();
}
+ public Object load(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException {
+ LoadEvent event = new LoadEvent(id, entityName, lockRequest, this);
+ fireLoad( event, LoadEventListener.LOAD );
+ return event.getResult();
+ }
+
public Object get(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException {
return get( entityClass.getName(), id, lockMode );
}
+ public Object get(Class entityClass, Serializable id, LockRequest lockRequest) throws HibernateException {
+ return get( entityClass.getName(), id, lockRequest );
+ }
+
public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
LoadEvent event = new LoadEvent(id, entityName, lockMode, this);
fireLoad(event, LoadEventListener.GET);
return event.getResult();
}
+ public Object get(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException {
+ LoadEvent event = new LoadEvent(id, entityName, lockRequest, this);
+ fireLoad(event, LoadEventListener.GET);
+ return event.getResult();
+ }
+
private void fireLoad(LoadEvent event, LoadType loadType) {
errorIfClosed();
checkTransactionSynchStatus();
@@ -1060,6 +1093,10 @@
fireRefresh( new RefreshEvent(object, lockMode, this) );
}
+ public void refresh(Object object, LockRequest lockRequest) throws HibernateException {
+ fireRefresh( new RefreshEvent(object, lockRequest, this) );
+ }
+
public void refresh(Object object, Map refreshedAlready) throws HibernateException {
fireRefresh( refreshedAlready, new RefreshEvent(object, this) );
}
Modified: core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -31,6 +31,7 @@
import org.hibernate.FetchMode;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
+import org.hibernate.LockRequest;
import org.hibernate.engine.CascadeStyle;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.LoadQueryInfluencers;
@@ -94,6 +95,29 @@
initStatementString( whereString, orderByString, lockMode);
}
+ protected final void initAll(
+ final String whereString,
+ final String orderByString,
+ final LockRequest lockRequest) throws MappingException {
+ walkEntityTree( persister, getAlias() );
+ List allAssociations = new ArrayList();
+ allAssociations.addAll(associations);
+ allAssociations.add(
+ new OuterJoinableAssociation(
+ persister.getEntityType(),
+ null,
+ null,
+ alias,
+ JoinFragment.LEFT_OUTER_JOIN,
+ null,
+ getFactory(),
+ CollectionHelper.EMPTY_MAP
+ )
+ );
+ initPersisters(allAssociations, lockRequest.getLockMode());
+ initStatementString( whereString, orderByString, lockRequest.getLockMode());
+ }
+
protected final void initProjection(
final String projectionString,
final String whereString,
Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/AbstractEntityLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/AbstractEntityLoader.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/AbstractEntityLoader.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -28,8 +28,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -33,6 +33,7 @@
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
+import org.hibernate.LockRequest;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.LoadQueryInfluencers;
@@ -128,4 +129,24 @@
}
}
+ public static UniqueEntityLoader createBatchingEntityLoader(
+ final OuterJoinLoadable persister,
+ final int maxBatchSize,
+ final LockRequest lockRequest,
+ final SessionFactoryImplementor factory,
+ final LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
+
+ if ( maxBatchSize>1 ) {
+ int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
+ Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
+ for ( int i=0; i<batchSizesToCreate.length; i++ ) {
+ loadersToCreate[i] = new EntityLoader(persister, batchSizesToCreate[i], lockRequest, factory, loadQueryInfluencers);
+ }
+ return new BatchingEntityLoader(persister, batchSizesToCreate, loadersToCreate);
+ }
+ else {
+ return new EntityLoader(persister, lockRequest, factory, loadQueryInfluencers);
+ }
+ }
+
}
Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -30,6 +30,7 @@
import org.hibernate.FetchMode;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
+import org.hibernate.LockRequest;
import org.hibernate.engine.CascadeStyle;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.LoadQueryInfluencers;
@@ -47,7 +48,7 @@
*/
public class EntityJoinWalker extends AbstractEntityJoinWalker {
- private final LockMode lockMode;
+ private final LockRequest lockRequest = new LockRequest();
public EntityJoinWalker(
OuterJoinLoadable persister,
@@ -58,15 +59,35 @@
LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
super( persister, factory, loadQueryInfluencers );
- this.lockMode = lockMode;
+ this.lockRequest.setLockMode(lockMode);
StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
//include the discriminator and class-level where, but not filters
.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
- initAll( whereCondition.toString(), "", lockMode );
+ initAll( whereCondition.toString(), "", lockRequest );
}
+ public EntityJoinWalker(
+ OuterJoinLoadable persister,
+ String[] uniqueKey,
+ int batchSize,
+ LockRequest lockRequest,
+ SessionFactoryImplementor factory,
+ LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
+ super( persister, factory, loadQueryInfluencers );
+
+ this.lockRequest.setLockMode(lockRequest.getLockMode());
+ this.lockRequest.setTimeOut(lockRequest.getTimeOut());
+ this.lockRequest.setScope(lockRequest.getScope());
+
+ StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
+ //include the discriminator and class-level where, but not filters
+ .append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
+
+ initAll( whereCondition.toString(), "", lockRequest);
+ }
+
protected int getJoinType(
OuterJoinLoadable persister,
String path,
@@ -81,7 +102,7 @@
// NOTE : we override this form here specifically to account for
// fetch profiles.
// TODO : how to best handle criteria queries?
- if ( lockMode.greaterThan( LockMode.READ ) ) {
+ if ( lockRequest.getLockMode().greaterThan( LockMode.READ ) ) {
return -1;
}
if ( isTooDeep( currentDepth )
Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -24,12 +24,10 @@
*/
package org.hibernate.loader.entity;
-import java.util.Map;
-import java.util.Set;
-
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
+import org.hibernate.LockRequest;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.LoadQueryInfluencers;
@@ -56,8 +54,16 @@
LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
this( persister, 1, lockMode, factory, loadQueryInfluencers );
}
-
+
public EntityLoader(
+ OuterJoinLoadable persister,
+ LockRequest lockRequest,
+ SessionFactoryImplementor factory,
+ LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
+ this( persister, 1, lockRequest, factory, loadQueryInfluencers );
+ }
+
+ public EntityLoader(
OuterJoinLoadable persister,
int batchSize,
LockMode lockMode,
@@ -75,6 +81,23 @@
}
public EntityLoader(
+ OuterJoinLoadable persister,
+ int batchSize,
+ LockRequest lockRequest,
+ SessionFactoryImplementor factory,
+ LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
+ this(
+ persister,
+ persister.getIdentifierColumnNames(),
+ persister.getIdentifierType(),
+ batchSize,
+ lockRequest,
+ factory,
+ loadQueryInfluencers
+ );
+ }
+
+ public EntityLoader(
OuterJoinLoadable persister,
String[] uniqueKey,
Type uniqueKeyType,
@@ -102,6 +125,34 @@
}
+ public EntityLoader(
+ OuterJoinLoadable persister,
+ String[] uniqueKey,
+ Type uniqueKeyType,
+ int batchSize,
+ LockRequest lockRequest,
+ SessionFactoryImplementor factory,
+ LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
+ super( persister, uniqueKeyType, factory, loadQueryInfluencers );
+
+ JoinWalker walker = new EntityJoinWalker(
+ persister,
+ uniqueKey,
+ batchSize,
+ lockRequest,
+ factory,
+ loadQueryInfluencers
+ );
+ initFromWalker( walker );
+
+ postInstantiate();
+
+ batchLoader = batchSize > 1;
+
+ log.debug( "Static select for entity " + entityName + ": " + getSQLString() );
+
+ }
+
public Object loadByUniqueKey(
SessionImplementor session,
Object key) throws HibernateException {
Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -46,6 +46,7 @@
import org.hibernate.QueryException;
import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException;
+import org.hibernate.LockRequest;
import org.hibernate.cache.CacheKey;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
import org.hibernate.cache.entry.CacheEntry;
@@ -1412,8 +1413,17 @@
Object object,
LockMode lockMode,
SessionImplementor session) throws HibernateException {
- getLocker( lockMode ).lock( id, version, object, -1, session );
+ getLocker( lockMode ).lock( id, version, object, LockRequest.WAIT_FOREVER, session );
}
+
+ public void lock(
+ Serializable id,
+ Object version,
+ Object object,
+ LockRequest lockRequest,
+ SessionImplementor session) throws HibernateException {
+ getLocker( lockRequest.getLockMode() ).lock( id, version, object, lockRequest.getTimeOut(), session );
+ }
public String getRootTableName() {
return getSubclassTableName( 0 );
@@ -1871,6 +1881,19 @@
);
}
+ protected UniqueEntityLoader createEntityLoader(
+ LockRequest lockRequest,
+ LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
+ //TODO: disable batch loading if lockMode > READ?
+ return BatchingEntityLoader.createBatchingEntityLoader(
+ this,
+ batchSize,
+ lockRequest,
+ getFactory(),
+ loadQueryInfluencers
+ );
+ }
+
protected UniqueEntityLoader createEntityLoader(LockMode lockMode) throws MappingException {
return createEntityLoader( lockMode, LoadQueryInfluencers.NONE );
}
@@ -3185,10 +3208,28 @@
);
}
- final UniqueEntityLoader loader = getAppropriateLoader( lockMode, session );
+ final UniqueEntityLoader loader = getAppropriateLoader( new LockRequest().setLockMode(lockMode), session );
return loader.load( id, optionalObject, session );
}
+ /**
+ * Load an instance using either the <tt>forUpdateLoader</tt> or the outer joining <tt>loader</tt>,
+ * depending upon the value of the <tt>lock</tt> parameter
+ */
+ public Object load(Serializable id, Object optionalObject, LockRequest lockRequest, SessionImplementor session)
+ throws HibernateException {
+
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ "Fetching entity: " +
+ MessageHelper.infoString( this, id, getFactory() )
+ );
+ }
+
+ final UniqueEntityLoader loader = getAppropriateLoader( lockRequest, session );
+ return loader.load( id, optionalObject, session );
+ }
+
public void registerAffectingFetchProfile(String fetchProfileName) {
affectingFetchProfileNames.add( fetchProfileName );
}
@@ -3208,7 +3249,7 @@
&& filterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEnabledFilters() );
}
- private UniqueEntityLoader getAppropriateLoader(LockMode lockMode, SessionImplementor session) {
+ private UniqueEntityLoader getAppropriateLoader(LockRequest lockRequest, SessionImplementor session) {
if ( queryLoader != null ) {
// if the user specified a custom query loader we need to that
// regardless of any other consideration
@@ -3217,9 +3258,9 @@
else if ( isAffectedByEnabledFilters( session ) ) {
// because filters affect the rows returned (because they add
// restirctions) these need to be next in precendence
- return createEntityLoader( lockMode, session.getLoadQueryInfluencers() );
+ return createEntityLoader( lockRequest, session.getLoadQueryInfluencers() );
}
- else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != null && LockMode.UPGRADE.greaterThan( lockMode ) ) {
+ else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != null && LockMode.UPGRADE.greaterThan( lockRequest.getLockMode() ) ) {
// Next, we consider whether an 'internal' fetch profile has been set.
// This indicates a special fetch profile Hibernate needs applied
// (for its merge loading process e.g.).
@@ -3228,10 +3269,10 @@
else if ( isAffectedByEnabledFetchProfiles( session ) ) {
// If the session has associated influencers we need to adjust the
// SQL query used for loading based on those influencers
- return createEntityLoader( lockMode, session.getLoadQueryInfluencers() );
+ return createEntityLoader( lockRequest, session.getLoadQueryInfluencers() );
}
else {
- return ( UniqueEntityLoader ) loaders.get( lockMode );
+ return ( UniqueEntityLoader ) loaders.get( lockRequest.getLockMode() );
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -31,6 +31,7 @@
import org.hibernate.LockMode;
import org.hibernate.MappingException;
import org.hibernate.EntityMode;
+import org.hibernate.LockRequest;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.cache.OptimisticCacheSource;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
@@ -327,12 +328,24 @@
throws HibernateException;
/**
+ * Load an instance of the persistent class.
+ */
+ public Object load(Serializable id, Object optionalObject, LockRequest lockRequest, SessionImplementor session)
+ throws HibernateException;
+
+ /**
* Do a version check (optional operation)
*/
public void lock(Serializable id, Object version, Object object, LockMode lockMode, SessionImplementor session)
throws HibernateException;
/**
+ * Do a version check (optional operation)
+ */
+ public void lock(Serializable id, Object version, Object object, LockRequest lockRequest, SessionImplementor session)
+ throws HibernateException;
+
+ /**
* Persist an instance
*/
public void insert(Serializable id, Object[] fields, Object object, SessionImplementor session)
Modified: core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -32,6 +32,7 @@
import java.util.List;
import org.hibernate.LockMode;
+import org.hibernate.LockRequest;
import org.hibernate.type.Type;
public final class ArrayHelper {
@@ -83,6 +84,12 @@
return array;
}
+ public static LockMode[] fillArray(LockRequest lockRequest, int length) {
+ LockMode[] array = new LockMode[length];
+ Arrays.fill(array, lockRequest);
+ return array;
+ }
+
public static String[] toStringArray(Collection coll) {
return (String[]) coll.toArray( new String[coll.size()] );
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -29,6 +29,7 @@
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
+import java.util.HashMap;
import javax.persistence.EntityNotFoundException;
import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
@@ -42,6 +43,7 @@
import javax.persistence.Query;
import javax.persistence.TransactionRequiredException;
import javax.persistence.TypedQuery;
+import javax.persistence.PessimisticLockScope;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.metamodel.Metamodel;
@@ -74,6 +76,8 @@
@SuppressWarnings("unchecked")
public abstract class AbstractEntityManagerImpl implements HibernateEntityManagerImplementor, Serializable {
private static final Logger log = LoggerFactory.getLogger( AbstractEntityManagerImpl.class );
+ private static final String PESSIMISTICLOCKSCOPE = "javax.persistence.lock.scope";
+ private static final String PESSIMISTICLOCKTIMEOUT= "javax.persistence.lock.timeout";
private EntityManagerFactoryImpl entityManagerFactory;
protected transient TransactionImpl tx = new TransactionImpl( this );
@@ -239,19 +243,22 @@
@SuppressWarnings("unchecked")
public <A> A find(Class<A> entityClass, Object primaryKey) {
- LockModeType lmt = null;
- return find( entityClass, primaryKey, lmt);
+ return find( entityClass, primaryKey, null, null);
}
public <T> T find(Class<T> entityClass, Object primaryKey, Map<String, Object> properties) {
- return find(entityClass, primaryKey);
+ return find(entityClass, primaryKey, null, null);
}
@SuppressWarnings("unchecked")
public <A> A find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType) {
+ return find(entityClass, primaryKey, lockModeType, null);
+ }
+
+ public <A> A find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) {
try {
if ( lockModeType != null )
- return ( A ) getSession().get( entityClass, ( Serializable ) primaryKey, getLockMode(lockModeType) );
+ return ( A ) getSession().get( entityClass, ( Serializable ) primaryKey, getLockRequest(lockModeType, properties) );
else
return ( A ) getSession().get( entityClass, ( Serializable ) primaryKey );
}
@@ -277,10 +284,6 @@
}
}
- public <A> A find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) {
- return find(entityClass, primaryKey, lockModeType);
- }
-
private void checkTransactionNeeded() {
if ( persistenceContextType == PersistenceContextType.TRANSACTION && !isTransactionInProgress() ) {
//no need to mark as rollback, no tx in progress
@@ -334,23 +337,25 @@
}
public void refresh(Object entity) {
- LockModeType lmt = null;
- refresh(entity, lmt);
+ refresh(entity, null, null);
}
public void refresh(Object entity, Map<String, Object> properties) {
- LockModeType lmt = null;
- refresh(entity, lmt);
+ refresh(entity, null, null);
}
public void refresh(Object entity, LockModeType lockModeType) {
+ refresh(entity, lockModeType, null);
+ }
+
+ public void refresh(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
checkTransactionNeeded();
try {
if ( !getSession().contains( entity ) ) {
throw new IllegalArgumentException( "Entity not managed" );
}
if(lockModeType != null)
- getSession().refresh( entity, getLockMode(lockModeType) );
+ getSession().refresh( entity, getLockRequest(lockModeType, properties) );
else
getSession().refresh( entity );
}
@@ -362,10 +367,6 @@
}
}
- public void refresh(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
- refresh(entity, lockModeType);
- }
-
public boolean contains(Object entity) {
try {
if ( entity != null
@@ -508,6 +509,10 @@
}
public void lock(Object entity, LockModeType lockMode) {
+ lock( entity, lockMode, null);
+ }
+
+ public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
try {
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
@@ -516,21 +521,42 @@
if ( !contains( entity ) ) {
throw new IllegalArgumentException( "entity not in the persistence context" );
}
- getSession().lock( entity, getLockMode( lockMode ) );
+ getSession().lock( entity, getLockRequest(lockModeType, properties) );
}
catch ( HibernateException he ) {
throw convert( he );
}
+
}
- public void lock(Object o, LockModeType lockModeType, Map<String, Object> properties) {
- // todo: support different properties passed in
- lock(o,lockModeType);
+ private LockRequest getLockRequest(LockModeType lockModeType, Map<String, Object> properties) {
+ LockRequest lockRequest = new LockRequest();
+ lockRequest.setLockMode(getLockMode(lockModeType));
+ if ( properties != null ) {
+ // lockRequest scope will default to false (PessimisticLockScope.NORMAL)
+ Object value = properties.get(PESSIMISTICLOCKSCOPE);
+ if ( value instanceof String && PessimisticLockScope.valueOf((String) value) == PessimisticLockScope.EXTENDED) {
+ lockRequest.setScope(true);
+ }
+ // lockRequest timeout will default to LockRequest.FOREVER_WAIT
+ value = properties.get(PESSIMISTICLOCKTIMEOUT);
+ if ( value instanceof String ) {
+ int timeout = Integer.parseInt((String) value);
+ if ( timeout < 0 ) {
+ lockRequest.setTimeOut(LockRequest.WAIT_FOREVER);
+ }
+ else if( timeout == 0 ) {
+ lockRequest.setTimeOut(LockRequest.NO_WAIT);
+ }
+ else {
+ lockRequest.setTimeOut(timeout);
+ }
+ }
+ }
+ return lockRequest;
}
-
- private LockModeType getLockModeType(LockMode lockMode)
- {
+ private LockModeType getLockModeType(LockMode lockMode) {
if ( lockMode == LockMode.NONE )
return LockModeType.NONE;
else if ( lockMode == LockMode.OPTIMISTIC || lockMode == LockMode.READ )
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java 2009-11-20 14:01:40 UTC (rev 18015)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java 2009-11-20 14:51:13 UTC (rev 18016)
@@ -11,6 +11,7 @@
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
+import org.hibernate.LockRequest;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.access.EntityRegionAccessStrategy;
@@ -280,6 +281,18 @@
}
/**
+ * @see EntityPersister#load(Serializable, Object, LockRequest, SessionImplementor)
+ */
+ public Object load(
+ Serializable id,
+ Object optionalObject,
+ LockRequest lockRequest,
+ SessionImplementor session
+ ) throws HibernateException {
+ return load(id, optionalObject, lockRequest.getLockMode(), session);
+ }
+
+ /**
* @see EntityPersister#load(Serializable, Object, LockMode, SessionImplementor)
*/
public Object load(
@@ -330,6 +343,20 @@
Serializable id,
Object version,
Object object,
+ LockRequest lockRequest,
+ SessionImplementor session
+ ) throws HibernateException {
+
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see EntityPersister#lock(Serializable, Object, Object, LockMode, SessionImplementor)
+ */
+ public void lock(
+ Serializable id,
+ Object version,
+ Object object,
LockMode lockMode,
SessionImplementor session
) throws HibernateException {
15 years
Hibernate SVN: r18015 - in search/trunk/src: main/java/org/hibernate/search/impl and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-11-20 09:01:40 -0500 (Fri, 20 Nov 2009)
New Revision: 18015
Added:
search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/Item.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProductCatalog.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProvidedIdEntry.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/SecurityFilterFactory.java
Modified:
search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java
search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java
search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java
search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java
search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/BlogEntry.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java
search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
Log:
HSEARCH-411 Get a feature complete programmatic mapping (Amin Mohammed-Coleman)
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/AnalyzerDefMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -69,11 +69,8 @@
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType,mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
- }
}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/CalendarBridgeMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,46 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.annotations.Resolution;
+
+public class CalendarBridgeMapping {
+
+ private final SearchMapping mapping;
+ private final Map<String, Object> resolution;
+ private EntityDescriptor entity;
+ private PropertyDescriptor property;
+
+ public CalendarBridgeMapping(SearchMapping mapping,EntityDescriptor entity,PropertyDescriptor property, Resolution resolution) {
+ if (resolution == null) {
+ throw new SearchException("Resolution required in order to index calendar property");
+ }
+ this.mapping = mapping;
+ this.resolution = new HashMap<String, Object>();
+ this.entity = entity;
+ this.property = property;
+ this.resolution.put("resolution", resolution);
+ property.setCalendarBridge(this.resolution);
+ }
+
+ public FieldMapping field() {
+ return new FieldMapping(property, entity, mapping);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/ContainedInMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,39 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+
+public class ContainedInMapping {
+
+ private final SearchMapping mapping;
+ private final PropertyDescriptor property;
+ private final EntityDescriptor entity;
+
+ public ContainedInMapping(SearchMapping mapping,PropertyDescriptor property, EntityDescriptor entity) {
+ this.mapping = mapping;
+ this.property = property;
+ this.entity = entity;
+ Map<String, Object> containedIn = new HashMap<String, Object>();
+ property.setContainedIn(containedIn);
+ }
+
+ public FieldMapping field() {
+ return new FieldMapping(property, entity, mapping);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/DateBridgeMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,47 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.annotations.Resolution;
+
+public class DateBridgeMapping {
+
+ private final SearchMapping mapping;
+ private final Map<String, Object> resolution;
+ private EntityDescriptor entity;
+ private PropertyDescriptor property;
+
+ public DateBridgeMapping(SearchMapping mapping,EntityDescriptor entity,PropertyDescriptor property, Resolution resolution) {
+ if (resolution == null) {
+ throw new SearchException("Resolution required in order to index calendar property");
+ }
+ this.mapping = mapping;
+ this.resolution = new HashMap<String, Object>();
+ this.entity = entity;
+ this.property = property;
+ this.resolution.put("resolution", resolution);
+ property.setDateBridge(this.resolution);
+ }
+
+
+ public FieldMapping field() {
+ return new FieldMapping(property, entity, mapping);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/DocumentIdMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -63,12 +63,8 @@
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
- }
-
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/EntityDescriptor.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -26,7 +26,9 @@
import java.lang.annotation.ElementType;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
/**
* @author Emmanuel Bernard
@@ -38,7 +40,10 @@
private Map<String, Object> similarity;
private Map<String, Object> boost;
private Map<String, Object> analyzerDiscriminator;
-
+ private Set<Map<String, Object>> fullTextFilterDefs = new HashSet<Map<String, Object>>();
+ private Map<String,Object> providedId;
+
+
public Map<String, Object> getIndexed() {
return indexed;
}
@@ -88,7 +93,24 @@
public Map<String, Object> getAnalyzerDiscriminator() {
return analyzerDiscriminator;
}
+
+ public Set<Map<String, Object>> getFullTextFilterDefs() {
+ return fullTextFilterDefs;
+ }
+
+ public void addFulltextFilterDef(Map<String, Object> fullTextFilterDef) {
+ fullTextFilterDefs.add(fullTextFilterDef);
+ }
+
+ public void setProvidedId(Map<String, Object> providedId) {
+ this.providedId = providedId;
+ }
+
+ public Map<String, Object> getProvidedId() {
+ return this.providedId;
+ }
+
private static class PropertyKey {
private String name;
private ElementType type;
@@ -126,4 +148,5 @@
return result;
}
}
+
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/EntityMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -29,7 +29,6 @@
import java.util.Map;
import org.apache.solr.analysis.TokenizerFactory;
-
import org.hibernate.search.analyzer.Discriminator;
/**
@@ -38,15 +37,16 @@
public class EntityMapping {
private SearchMapping mapping;
private EntityDescriptor entity;
-
- public EntityMapping(Class<?> entityType, String name, SearchMapping mapping) {
+
+ public EntityMapping(Class<?> entityType, SearchMapping mapping) {
this.mapping = mapping;
entity = mapping.getEntity(entityType);
- Map<String, Object> indexed = new HashMap<String, Object>();
- if (name != null) indexed.put( "index", name );
- entity.setIndexed(indexed);
}
-
+
+ public IndexedMapping indexed() {
+ return new IndexedMapping(mapping,entity, this);
+ }
+
public EntityMapping similarity(Class<?> impl) {
Map<String, Object> similarity = new HashMap<String, Object>(1);
similarity.put( "impl", impl );
@@ -67,7 +67,12 @@
entity.setAnalyzerDiscriminator(discriminatorAnn);
return this;
}
-
+
+
+ public FullTextFilterDefMapping fullTextFilterDef(String name, Class<?> impl) {
+ return new FullTextFilterDefMapping(mapping, entity, name, impl);
+ }
+
public PropertyMapping property(String name, ElementType type) {
return new PropertyMapping(name, type, entity, mapping);
}
@@ -76,11 +81,12 @@
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
+ public ProvidedIdMapping providedId() {
+ return new ProvidedIdMapping(mapping,entity);
}
+
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldBridgeMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -108,11 +108,8 @@
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
- }
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FieldMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -31,6 +31,7 @@
import org.apache.solr.analysis.TokenizerFactory;
import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TermVector;
@@ -103,16 +104,20 @@
return new PropertyMapping(name, type, entity, mapping);
}
+ public DateBridgeMapping dateBridge(Resolution resolution) {
+ return new DateBridgeMapping(mapping, entity, property, resolution);
+ }
+
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
+ public CalendarBridgeMapping calendarBridge(Resolution resolution) {
+ return new CalendarBridgeMapping(mapping,entity,property, resolution);
}
}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/FullTextFilterDefMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,60 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+import org.hibernate.search.annotations.FilterCacheModeType;
+
+/**
+ * Mapping class responsible for collecting data for constructing
+ * FullTextFilterDef annotation.
+ */
+public class FullTextFilterDefMapping {
+
+ private final SearchMapping mapping;
+ private final Map<String,Object> fullTextFilterDef;
+ private final EntityDescriptor entity;
+
+ public FullTextFilterDefMapping(SearchMapping mapping, EntityDescriptor entity, String name, Class<?> impl) {
+ this.mapping = mapping;
+ this.entity = entity;
+ this.fullTextFilterDef =new HashMap<String, Object>();
+ this.fullTextFilterDef.put("name", name);
+ this.fullTextFilterDef.put("impl", impl);
+ entity.addFulltextFilterDef(fullTextFilterDef);
+ }
+
+ /**
+ * Add cache implementation for fulltextfilterdef mapping
+ * @param cache
+ * @return FullTextFilterDefMapping
+ */
+ public FullTextFilterDefMapping cache(FilterCacheModeType cache) {
+ this.fullTextFilterDef.put("cache", cache);
+ return this;
+ }
+
+ public FullTextFilterDefMapping fullTextFilterDef(String name, Class<?> impl) {
+ return new FullTextFilterDefMapping(mapping,entity,name, impl);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+ public ProvidedIdMapping providedId() {
+ return new ProvidedIdMapping(mapping,entity);
+ }
+
+
+}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/IndexEmbeddedMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,56 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+
+public class IndexEmbeddedMapping {
+
+ private final SearchMapping mapping;
+ private final Map<String,Object> indexEmbedded;
+ private EntityDescriptor entity;
+ private PropertyDescriptor property;
+
+
+ public IndexEmbeddedMapping(SearchMapping mapping, PropertyDescriptor property, EntityDescriptor entity) {
+ this.mapping = mapping;
+ this.indexEmbedded = new HashMap<String, Object>();
+ this.property = property;
+ this.entity = entity;
+ this.property.setIndexEmbedded(indexEmbedded);
+ }
+
+ public IndexEmbeddedMapping prefix(String prefix) {
+ this.indexEmbedded.put("prefix",prefix);
+ return this;
+ }
+
+ public IndexEmbeddedMapping targetElement(Class<?> targetElement) {
+ this.indexEmbedded.put("targetElement",targetElement);
+ return this;
+ }
+
+ public IndexEmbeddedMapping depth(int depth) {
+ this.indexEmbedded.put("depth", depth);
+ return this;
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+ public FieldMapping field() {
+ return new FieldMapping(property, entity, mapping);
+ }
+
+}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/IndexedMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,72 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+import org.hibernate.search.analyzer.Discriminator;
+
+public class IndexedMapping {
+
+ private final SearchMapping mapping;
+ private final EntityDescriptor entity;
+ private final Map<String, Object> indexed;
+ private final EntityMapping entityMapping;
+
+ public IndexedMapping(SearchMapping mapping, EntityDescriptor entity, EntityMapping entityMapping) {
+ this.entityMapping = entityMapping;
+ this.mapping = mapping;
+ this.entity = entity;
+ indexed = new HashMap<String, Object>();
+ entity.setIndexed(indexed);
+ }
+
+ public EntityMapping indexName(String indexName) {
+ this.indexed.put("index", indexName);
+ return entityMapping;
+ }
+
+ public IndexedMapping similarity(Class<?> impl) {
+ Map<String, Object> similarity = new HashMap<String, Object>(1);
+ similarity.put( "impl", impl );
+ entity.setSimilariy(similarity);
+ return this;
+ }
+
+ public IndexedMapping boost(float boost) {
+ final Map<String, Object> boostAnn = new HashMap<String, Object>();
+ boostAnn.put( "value", boost );
+ entity.setBoost(boostAnn);
+ return this;
+ }
+
+ public IndexedMapping analyzerDiscriminator(Class<? extends Discriminator> discriminator) {
+ final Map<String, Object> discriminatorAnn = new HashMap<String, Object>();
+ discriminatorAnn.put( "impl", discriminator );
+ entity.setAnalyzerDiscriminator(discriminatorAnn);
+ return this;
+ }
+
+
+ public FullTextFilterDefMapping fullTextFilterDef(String name, Class<?> impl) {
+ return new FullTextFilterDefMapping(mapping, entity, name, impl);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, mapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
+ }
+
+ public ProvidedIdMapping providedId() {
+ return new ProvidedIdMapping(mapping,entity);
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/PropertyDescriptor.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -25,9 +25,10 @@
package org.hibernate.search.cfg;
import java.lang.annotation.ElementType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Collection;
-import java.util.ArrayList;
/**
* @author Emmanuel Bernard
@@ -36,6 +37,11 @@
private ElementType type;
private String name;
private Collection<Map<String, Object>> fields = new ArrayList<Map<String, Object>>();
+ private Map<String, Object> dateBridge= new HashMap<String, Object>();
+ private Map<String, Object> calendarBridge= new HashMap<String, Object>();
+ private Map<String,Object> indexEmbedded;
+ private Map<String,Object> containedIn;
+
private Map<String, Object> documentId;
private Map<String, Object> analyzerDiscriminator;
@@ -52,6 +58,13 @@
fields.add( field );
}
+ public void setDateBridge(Map<String,Object> dateBridge) {
+ this.dateBridge = dateBridge;
+ }
+ public void setCalendarBridge(Map<String,Object> calendarBridge) {
+ this.calendarBridge = calendarBridge;
+ }
+
public Collection<Map<String, Object>> getFields() {
return fields;
}
@@ -64,7 +77,32 @@
return analyzerDiscriminator;
}
+
+ public Map<String, Object> getDateBridge() {
+ return dateBridge;
+ }
+ public Map<String, Object> getCalendarBridge() {
+ return calendarBridge;
+ }
+
+
public void setAnalyzerDiscriminator(Map<String, Object> analyzerDiscriminator) {
this.analyzerDiscriminator = analyzerDiscriminator;
}
+
+ public Map<String, Object> getIndexEmbedded() {
+ return indexEmbedded;
+ }
+
+ public void setIndexEmbedded(Map<String, Object> indexEmbedded) {
+ this.indexEmbedded = indexEmbedded;
+ }
+ public Map<String, Object> getContainedIn() {
+ return containedIn;
+ }
+
+ public void setContainedIn(Map<String, Object> containedIn) {
+ this.containedIn = containedIn;
+ }
+
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/PropertyMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -31,6 +31,7 @@
import org.apache.solr.analysis.TokenizerFactory;
import org.hibernate.search.analyzer.Discriminator;
+import org.hibernate.search.annotations.Resolution;
/**
* @author Emmanuel Bernard
@@ -54,6 +55,14 @@
return new FieldMapping(property, entity, mapping);
}
+ public DateBridgeMapping dateBridge(Resolution resolution) {
+ return new DateBridgeMapping(mapping, entity, property, resolution);
+ }
+
+ public CalendarBridgeMapping calendarBridge(Resolution resolution) {
+ return new CalendarBridgeMapping(mapping, entity, property, resolution);
+ }
+
public PropertyMapping analyzerDiscriminator(Class<? extends Discriminator> discriminator) {
Map<String, Object> analyzerDiscriminatorAnn = new HashMap<String, Object>();
analyzerDiscriminatorAnn.put( "impl", discriminator );
@@ -69,11 +78,15 @@
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
+ public IndexEmbeddedMapping indexEmbedded() {
+ return new IndexEmbeddedMapping(mapping,property,entity);
}
+
+ public ContainedInMapping containedIn() {
+ return new ContainedInMapping(mapping, property, entity);
+ }
}
Added: search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.java (rev 0)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/ProvidedIdMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,47 @@
+package org.hibernate.search.cfg;
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.solr.analysis.TokenizerFactory;
+
+public class ProvidedIdMapping {
+
+ private final SearchMapping searchMapping;
+ private final Map<String,Object> providedIdMapping;
+ private EntityDescriptor entity;
+
+ public ProvidedIdMapping(SearchMapping searchMapping, EntityDescriptor entity) {
+ this.searchMapping = searchMapping;
+ this.entity =entity;
+ providedIdMapping = new HashMap<String,Object>();
+ entity.setProvidedId(providedIdMapping);
+ }
+
+ public ProvidedIdMapping name(String name) {
+ this.providedIdMapping.put("name", name);
+ return this;
+ }
+
+ public FieldBridgeMapping bridge(Class<?> impl) {
+ return new FieldBridgeMapping( impl, providedIdMapping, null, null, entity, searchMapping );
+ }
+
+ public FullTextFilterDefMapping fullTextFilterDef(String name, Class<?> impl) {
+ return new FullTextFilterDefMapping(searchMapping, entity, name, impl);
+ }
+
+ public PropertyMapping property(String name, ElementType type) {
+ return new PropertyMapping(name, type, entity, searchMapping);
+ }
+
+ public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
+ return new AnalyzerDefMapping(name, tokenizerFactory, searchMapping);
+ }
+
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, searchMapping);
+ }
+
+}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/SearchMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -43,7 +43,7 @@
public Set<Map<String, Object>> getAnalyzerDefs() {
return analyzerDefs;
}
-
+
public EntityDescriptor getEntityDescriptor(Class<?> entityType) {
return entities.get( entityType );
}
@@ -52,14 +52,10 @@
return new AnalyzerDefMapping(name, tokenizerFactory, this);
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, this);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, this);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, this);
- }
-
/**
* eg @Containing(things={@Thing(...), @Thing(...)}
* Map<String, Object> addedThing = addElementToAnnotationArray(containing, "things");
@@ -88,4 +84,5 @@
}
return entity;
}
+
}
Modified: search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/cfg/TokenFilterDefMapping.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -61,14 +61,10 @@
return new TokenFilterDefMapping(factory, analyzerDef, mapping );
}
- public EntityMapping indexedClass(Class<?> entityType) {
- return new EntityMapping(entityType, null, mapping);
+ public EntityMapping entity(Class<?> entityType) {
+ return new EntityMapping(entityType, mapping);
}
- public EntityMapping indexedClass(Class<?> entityType, String indexName) {
- return new EntityMapping(entityType, indexName, mapping);
- }
-
public AnalyzerDefMapping analyzerDef(String name, Class<? extends TokenizerFactory> tokenizerFactory) {
return new AnalyzerDefMapping(name, tokenizerFactory, mapping);
}
Modified: search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -24,41 +24,50 @@
*/
package org.hibernate.search.impl;
-import java.util.Map;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Collection;
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.beans.Introspector;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
+import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
+import org.hibernate.annotations.common.reflection.AnnotationReader;
+import org.hibernate.annotations.common.reflection.Filter;
import org.hibernate.annotations.common.reflection.MetadataProvider;
-import org.hibernate.annotations.common.reflection.AnnotationReader;
import org.hibernate.annotations.common.reflection.ReflectionUtil;
-import org.hibernate.annotations.common.reflection.Filter;
-import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
-import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
-import org.hibernate.search.cfg.SearchMapping;
-import org.hibernate.search.cfg.EntityDescriptor;
-import org.hibernate.search.cfg.PropertyDescriptor;
import org.hibernate.search.SearchException;
-import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Analyzer;
-import org.hibernate.search.annotations.Fields;
import org.hibernate.search.annotations.AnalyzerDef;
-import org.hibernate.search.annotations.TokenizerDef;
-import org.hibernate.search.annotations.Parameter;
-import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.AnalyzerDefs;
+import org.hibernate.search.annotations.AnalyzerDiscriminator;
import org.hibernate.search.annotations.Boost;
+import org.hibernate.search.annotations.CalendarBridge;
+import org.hibernate.search.annotations.ContainedIn;
+import org.hibernate.search.annotations.DateBridge;
+import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.FieldBridge;
+import org.hibernate.search.annotations.Fields;
+import org.hibernate.search.annotations.FullTextFilterDef;
+import org.hibernate.search.annotations.FullTextFilterDefs;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.ProvidedId;
import org.hibernate.search.annotations.Similarity;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.AnalyzerDiscriminator;
+import org.hibernate.search.annotations.TokenFilterDef;
+import org.hibernate.search.annotations.TokenizerDef;
+import org.hibernate.search.cfg.EntityDescriptor;
+import org.hibernate.search.cfg.PropertyDescriptor;
+import org.hibernate.search.cfg.SearchMapping;
/**
* @author Emmanuel Bernard
@@ -114,7 +123,8 @@
}
return defs;
}
-
+
+
private AnalyzerDef createAnalyzerDef(Map<String, Object> analyzerDef) {
AnnotationDescriptor analyzerDefAnnotation = new AnnotationDescriptor( AnalyzerDef.class );
for ( Map.Entry<String, Object> entry : analyzerDef.entrySet() ) {
@@ -133,7 +143,7 @@
analyzerDefAnnotation.setValue( "tokenizer", AnnotationFactory.create( tokenizerAnnotation ) );
}
else if ( entry.getKey().equals( "filters" ) ) {
- TokenFilterDef[] filtersArray = createFilters( (List<Map<String, Object>>) entry.getValue() );
+ @SuppressWarnings("unchecked") TokenFilterDef[] filtersArray = createFilters( (List<Map<String, Object>>) entry.getValue() );
analyzerDefAnnotation.setValue( "filters", filtersArray );
}
else {
@@ -144,7 +154,7 @@
}
static private void addParamsToAnnotation(AnnotationDescriptor annotationDescriptor, Map.Entry<String, Object> entry) {
- Parameter[] paramsArray = createParams( ( List<Map<String, Object>> ) entry.getValue() );
+ @SuppressWarnings("unchecked") Parameter[] paramsArray = createParams( ( List<Map<String, Object>> ) entry.getValue() );
annotationDescriptor.setValue( "params", paramsArray );
}
@@ -193,7 +203,7 @@
this.delegate = delegate.getAnnotationReader( el );
this.mapping = mapping;
if ( el instanceof Class ) {
- entityType = (Class) el;
+ entityType = (Class<?>) el;
}
else if ( el instanceof Field ) {
Field field = (Field) el;
@@ -254,6 +264,9 @@
createDocumentId( property );
createAnalyzerDiscriminator( property );
createFields( property );
+ createIndexEmbedded(property);
+ createContainedIn(property);
+
}
}
}
@@ -266,6 +279,24 @@
}
}
+ private void createDateBridge(PropertyDescriptor property) {
+ Map<String, Object> map = property.getDateBridge();
+ for(Map.Entry<String, Object> entry: map.entrySet()) {
+ AnnotationDescriptor dateBrigeAnnotation = new AnnotationDescriptor( DateBridge.class );
+ dateBrigeAnnotation.setValue(entry.getKey(), entry.getValue());
+ annotations.put( DateBridge.class, AnnotationFactory.create( dateBrigeAnnotation ) );
+ }
+ }
+
+ private void createCalendarBridge(PropertyDescriptor property) {
+ Map<String, Object> map = property.getCalendarBridge();
+ for(Map.Entry<String, Object> entry: map.entrySet()) {
+ AnnotationDescriptor calendarBrigeAnnotation = new AnnotationDescriptor( CalendarBridge.class );
+ calendarBrigeAnnotation.setValue(entry.getKey(), entry.getValue());
+ annotations.put( CalendarBridge.class, AnnotationFactory.create( calendarBrigeAnnotation ) );
+ }
+ }
+
private void createDocumentId(PropertyDescriptor property) {
Map<String, Object> documentId = property.getDocumentId();
if (documentId != null) {
@@ -276,7 +307,7 @@
annotations.put( DocumentId.class, AnnotationFactory.create( documentIdAnnotation ) );
}
}
-
+
private void createAnalyzerDiscriminator(PropertyDescriptor property) {
Map<String, Object> analyzerDiscriminator = property.getAnalyzerDiscriminator();
if (analyzerDiscriminator != null) {
@@ -340,15 +371,45 @@
final org.hibernate.search.annotations.Field[] fieldAsArray = fieldAnnotations.toArray( fieldArray );
fieldsAnnotation.setValue( "value", fieldAsArray );
annotations.put( Fields.class, AnnotationFactory.create( fieldsAnnotation ) );
+ createDateBridge(property);
+ createCalendarBridge(property);
}
+
+
+ private void createContainedIn(PropertyDescriptor property) {
+ if (property.getContainedIn() != null) {
+ Map<String, Object> containedIn = property.getContainedIn();
+ AnnotationDescriptor containedInAnn = new AnnotationDescriptor( ContainedIn.class );
+ Set<Entry<String,Object>> entrySet = containedIn.entrySet();
+ for (Entry<String, Object> entry : entrySet) {
+ containedInAnn.setValue(entry.getKey(), entry.getValue());
+ }
+ annotations.put(ContainedIn.class,AnnotationFactory.create(containedInAnn));
+ }
+ }
+
+ private void createIndexEmbedded(PropertyDescriptor property) {
+ Map<String, Object> indexEmbedded = property.getIndexEmbedded();
+ if (indexEmbedded != null) {
+ AnnotationDescriptor indexEmbeddedAnn = new AnnotationDescriptor(IndexedEmbedded.class);
+ Set<Entry<String,Object>> entrySet = indexEmbedded.entrySet();
+ for (Entry<String, Object> entry : entrySet) {
+ indexEmbeddedAnn.setValue(entry.getKey(), entry.getValue());
+ }
+ annotations.put(IndexedEmbedded.class, AnnotationFactory.create(indexEmbeddedAnn));
+ }
+ }
+
private void createIndexed(EntityDescriptor entity) {
Class<? extends Annotation> annotationType = Indexed.class;
AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType );
- for ( Map.Entry<String, Object> entry : entity.getIndexed().entrySet() ) {
- annotation.setValue( entry.getKey(), entry.getValue() );
+ if (entity.getIndexed() != null) {
+ for ( Map.Entry<String, Object> entry : entity.getIndexed().entrySet() ) {
+ annotation.setValue( entry.getKey(), entry.getValue() );
+ }
+ annotations.put( annotationType, AnnotationFactory.create( annotation ) );
}
- annotations.put( annotationType, AnnotationFactory.create( annotation ) );
if ( entity.getSimilarity() != null ) {
annotation = new AnnotationDescriptor( Similarity.class );
@@ -373,8 +434,62 @@
}
annotations.put( AnalyzerDiscriminator.class, AnnotationFactory.create( annotation ) );
}
+ if (entity.getFullTextFilterDefs().size() > 0) {
+ AnnotationDescriptor fullTextFilterDefsAnnotation = new AnnotationDescriptor( FullTextFilterDefs.class );
+ FullTextFilterDef[] fullTextFilterDefArray = createFullTextFilterDefArray(entity);
+ fullTextFilterDefsAnnotation.setValue("value", fullTextFilterDefArray);
+ annotations.put( FullTextFilterDefs.class, AnnotationFactory.create( fullTextFilterDefsAnnotation ) );
+ }
+ if (entity.getProvidedId() != null) {
+ createProvidedId(entity);
+ }
}
+ private void createProvidedId(EntityDescriptor entity) {
+ AnnotationDescriptor annotation = new AnnotationDescriptor( ProvidedId.class );
+ Set<Entry<String,Object>> entrySet = entity.getProvidedId().entrySet();
+ for (Entry<String, Object> entry : entrySet) {
+ if (entry.getKey().equals("bridge")) {
+ AnnotationDescriptor bridgeAnnotation = new AnnotationDescriptor( FieldBridge.class );
+ @SuppressWarnings("unchecked")
+ Map<String, Object> bridge = (Map<String, Object>) entry.getValue();
+ for( Map.Entry<String, Object> bridgeEntry : bridge.entrySet() ) {
+ if ( bridgeEntry.getKey().equals( "params" ) ) {
+ addParamsToAnnotation( bridgeAnnotation, bridgeEntry );
+ }
+ else {
+ bridgeAnnotation.setValue( bridgeEntry.getKey(), bridgeEntry.getValue() );
+ }
+ }
+ annotation.setValue( "bridge", AnnotationFactory.create( bridgeAnnotation ) );
+ } else {
+ annotation.setValue(entry.getKey(), entry.getValue());
+ }
+ }
+ annotations.put( ProvidedId.class, AnnotationFactory.create( annotation ) );
+ }
+
+
+ private FullTextFilterDef[] createFullTextFilterDefArray(EntityDescriptor entity) {
+ Set<Map<String, Object>> fullTextFilterDefs = entity.getFullTextFilterDefs();
+ FullTextFilterDef[] filters = new FullTextFilterDef[fullTextFilterDefs.size()];
+ int index = 0;
+ for(Map<String,Object> filterDef : fullTextFilterDefs) {
+ filters[index] = createFullTextFilterDef(filterDef);
+ index++;
+ }
+ return filters;
+ }
+
+ private FullTextFilterDef createFullTextFilterDef(Map<String,Object> filterDef) {
+ AnnotationDescriptor fullTextFilterDefAnnotation = new AnnotationDescriptor( FullTextFilterDef.class );
+ for (Entry<String, Object> entry : filterDef.entrySet()) {
+ fullTextFilterDefAnnotation.setValue(entry.getKey(), entry.getValue());
+ }
+
+ return AnnotationFactory.create( fullTextFilterDefAnnotation );
+ }
+
private void populateAnnotationArray() {
annotationsArray = new Annotation[ annotations.size() ];
int index = 0;
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Address.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -24,11 +24,16 @@
*/
package org.hibernate.search.test.configuration;
+import java.util.Calendar;
+import java.util.Date;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
+import org.hibernate.search.test.embedded.nested.Place;
+
/**
* @author Emmanuel Bernard
*/
@@ -41,7 +46,10 @@
private String street2;
@ManyToOne
private Country country;
-
+ private Date dateCreated;
+ private Calendar lastUpdated;
+ private String owner;
+
public Long getAddressId() {
return addressId;
}
@@ -69,4 +77,29 @@
public void setStreet2(String street2) {
this.street2 = street2;
}
+
+ public Calendar getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Calendar lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ public void setDateCreated(Date dateCreated) {
+ this.dateCreated = dateCreated;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public String getOwner() {
+ return this.owner;
+ }
+
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/BlogEntry.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/BlogEntry.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/BlogEntry.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -1,22 +1,21 @@
package org.hibernate.search.test.configuration;
+import java.util.Date;
+
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-import org.apache.solr.analysis.StandardTokenizerFactory;
-import org.apache.solr.analysis.LowerCaseFilterFactory;
import org.apache.solr.analysis.EnglishPorterFilterFactory;
import org.apache.solr.analysis.GermanStemFilterFactory;
-
+import org.apache.solr.analysis.LowerCaseFilterFactory;
+import org.apache.solr.analysis.StandardTokenizerFactory;
+import org.hibernate.search.analyzer.Discriminator;
+import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.AnalyzerDefs;
import org.hibernate.search.annotations.Indexed;
-import org.hibernate.search.annotations.AnalyzerDefs;
-import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.TokenizerDef;
-import org.hibernate.search.annotations.TokenFilterDef;
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.AnalyzerDiscriminator;
-import org.hibernate.search.analyzer.Discriminator;
/**
* @author Emmanuel Bernard
@@ -43,6 +42,7 @@
private String language;
private String title;
private String description;
+ private Date dateCreated;
@Id @GeneratedValue
public Long getId() {
@@ -77,6 +77,13 @@
this.description = description;
}
+ public Date getDateCreated() {
+ return dateCreated;
+ }
+
+ public void setDateCreated(Date dateCreated) {
+ this.dateCreated = dateCreated;
+ }
public static class BlogLangDiscriminator implements Discriminator {
public String getAnalyzerDefinitionName(Object value, Object entity, String field) {
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Country.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -24,9 +24,13 @@
*/
package org.hibernate.search.test.configuration;
+import java.util.HashSet;
+import java.util.Set;
+
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.OneToMany;
/**
* @author Emmanuel Bernard
@@ -36,7 +40,18 @@
@Id
@GeneratedValue
private Long id;
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
private String name;
+
+ @OneToMany(mappedBy = "country")
+ private Set<Address> addresses = new HashSet<Address>();;
public String getName() {
return name;
@@ -45,4 +60,12 @@
public void setName(String name) {
this.name = name;
}
+
+ public void addAddress(Address address) {
+ addresses.add( address );
+ }
+
+ public Set<Address> getAddresses() {
+ return this.addresses;
+ }
}
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/Item.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/Item.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/Item.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,45 @@
+package org.hibernate.search.test.configuration;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Item {
+
+ @Id @GeneratedValue
+ private Integer id;
+ private String description;
+
+
+ @ManyToOne( cascade = { CascadeType.PERSIST, CascadeType.REMOVE } )
+ private ProductCatalog productCatalog;
+
+ public ProductCatalog getProductCatalog() {
+ return productCatalog;
+ }
+
+ public void setProductCatalog(ProductCatalog productCatalog) {
+ this.productCatalog = productCatalog;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProductCatalog.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProductCatalog.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProductCatalog.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,51 @@
+package org.hibernate.search.test.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+import org.hibernate.annotations.Cascade;
+import org.hibernate.annotations.IndexColumn;
+
+@Entity
+public class ProductCatalog {
+
+ @Id @GeneratedValue
+ private Integer id;
+ private String name;
+
+ @OneToMany(fetch = FetchType.LAZY)
+ @IndexColumn(name = "list_position")
+ @Cascade(org.hibernate.annotations.CascadeType.ALL)
+ private List<Item> items = new ArrayList<Item>();
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ public void addItem(Item item) {
+ this.items.add(item);
+ }
+}
Modified: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-11-20 11:21:01 UTC (rev 18014)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProgrammaticMappingTest.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -25,30 +25,41 @@
package org.hibernate.search.test.configuration;
import java.lang.annotation.ElementType;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
+import java.util.TimeZone;
-import org.apache.solr.analysis.StandardTokenizerFactory;
-import org.apache.solr.analysis.SnowballPorterFilterFactory;
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.DefaultSimilarity;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TopDocs;
+import org.apache.solr.analysis.EnglishPorterFilterFactory;
+import org.apache.solr.analysis.GermanStemFilterFactory;
import org.apache.solr.analysis.LowerCaseFilterFactory;
import org.apache.solr.analysis.NGramFilterFactory;
-import org.apache.solr.analysis.EnglishPorterFilterFactory;
-import org.apache.solr.analysis.GermanStemFilterFactory;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.search.DefaultSimilarity;
-
+import org.apache.solr.analysis.SnowballPorterFilterFactory;
+import org.apache.solr.analysis.StandardTokenizerFactory;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.annotations.FilterCacheModeType;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.bridge.builtin.LongBridge;
+import org.hibernate.search.cfg.ConcatStringBridge;
import org.hibernate.search.cfg.SearchMapping;
-import org.hibernate.search.cfg.ConcatStringBridge;
-import org.hibernate.search.annotations.Store;
-import org.hibernate.search.annotations.Index;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
import org.hibernate.search.test.analyzer.inheritance.ISOLatin1Analyzer;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.Transaction;
/**
* @author Emmanuel Bernard
@@ -177,6 +188,9 @@
s.close();
}
+
+
+
public void testAnalyzerDiscriminator() throws Exception{
FullTextSession s = Search.getFullTextSession( openSession() );
Transaction tx = s.beginTransaction();
@@ -213,6 +227,280 @@
s.close();
}
+
+ public void testDateBridgeMapping() throws Exception{
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ Address address = new Address();
+ address.setStreet1( "Peachtree Rd NE" );
+ address.setStreet2( "Peachtnot Rd NE" );
+ Calendar c = GregorianCalendar.getInstance();
+ c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
+ c.set( 2009, Calendar.NOVEMBER, 15);
+
+ Date date = new Date( c.getTimeInMillis() );
+ address.setDateCreated(date);
+ s.persist( address );
+
+ address = new Address();
+ address.setStreet1( "Peachtnot Rd NE" );
+ address.setStreet2( "Peachtree Rd NE" );
+ address.setDateCreated(date);
+ s.persist( address );
+
+ BlogEntry enEntry = new BlogEntry();
+ enEntry.setTitle( "acknowledgment" );
+ enEntry.setDescription( "acknowledgment" );
+ enEntry.setLanguage( "en" );
+ enEntry.setDateCreated(date);
+ s.persist( enEntry );
+
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "date-created:20091115 OR blog-entry-created:20091115" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting 3 results", 3, query.getResultSize() );
+
+ @SuppressWarnings( "unchecked" )
+ List<Object[]> results = query.list();
+
+ for( Object[] result : results ) {
+ s.delete( result[0] );
+ }
+ tx.commit();
+ s.close();
+ }
+
+ public void testCalendarBridgeMapping() throws Exception{
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ Address address = new Address();
+ address.setStreet1( "Peachtree Rd NE" );
+ address.setStreet2( "Peachtnot Rd NE" );
+ Calendar c = GregorianCalendar.getInstance();
+ c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
+ c.set( 2009, Calendar.NOVEMBER, 15);
+
+ address.setLastUpdated(c);
+ s.persist( address );
+
+ address = new Address();
+ address.setStreet1( "Peachtnot Rd NE" );
+ address.setStreet2( "Peachtree Rd NE" );
+ address.setLastUpdated(c);
+ s.persist( address );
+
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "last-updated:20091115" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting 2 results", 2, query.getResultSize() );
+
+ @SuppressWarnings( "unchecked" )
+ List<Object[]> results = query.list();
+
+ for( Object[] result : results ) {
+ s.delete( result[0] );
+ }
+ tx.commit();
+ s.close();
+ }
+
+
+ public void testProvidedIdMapping() throws Exception{
+ ProvidedIdEntry person1 = new ProvidedIdEntry();
+ person1.setName( "Big Goat" );
+ person1.setBlurb( "Eats grass" );
+
+ ProvidedIdEntry person2 = new ProvidedIdEntry();
+ person2.setName( "Mini Goat" );
+ person2.setBlurb( "Eats cheese" );
+
+ ProvidedIdEntry person3 = new ProvidedIdEntry();
+ person3.setName( "Regular goat" );
+ person3.setBlurb( "Is anorexic" );
+
+ Session session = openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ Transaction transaction = session.beginTransaction();
+ session.persist( person1 );
+ session.persist( person2 );
+ session.persist( person3 );
+
+ transaction.commit();
+ session.clear();
+
+ transaction = fullTextSession.beginTransaction();
+
+ QueryParser parser = new QueryParser( "providedidentry.name", new StandardAnalyzer() );
+ Query luceneQuery = parser.parse( "Goat" );
+
+ //we cannot use FTQuery because @ProvidedId does not provide the getter id and Hibernate Hsearch Query extension
+ //needs it. So we use plain Lucene
+
+ //we know there is only one DP
+ DirectoryProvider<?> provider = fullTextSession.getSearchFactory()
+ .getDirectoryProviders( ProvidedIdEntry.class )[0];
+ IndexSearcher searcher = new IndexSearcher( provider.getDirectory() );
+ TopDocs hits = searcher.search( luceneQuery, 1000 );
+ searcher.close();
+ transaction.commit();
+ session.close();
+
+ assertEquals( 3, hits.totalHits );
+ }
+
+
+
+ public void testFullTextFilterDef() throws Exception{
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ Address address = new Address();
+ address.setStreet1( "Peachtree Rd NE" );
+ address.setStreet2( "Peachtnot Rd NE" );
+ address.setOwner("test");
+ Calendar c = GregorianCalendar.getInstance();
+ c.setTimeZone( TimeZone.getTimeZone( "GMT" ) ); //for the sake of tests
+ c.set( 2009, Calendar.NOVEMBER, 15);
+
+ address.setLastUpdated(c);
+ s.persist( address );
+
+ address = new Address();
+ address.setStreet1( "Peachtnot Rd NE" );
+ address.setStreet2( "Peachtree Rd NE" );
+ address.setLastUpdated(c);
+ address.setOwner("test2");
+ s.persist( address );
+
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "street1:Peachtnot" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ query.enableFullTextFilter("security").setParameter("ownerName", "test");
+ assertEquals( "expecting 1 results", 1, query.getResultSize() );
+
+ @SuppressWarnings( "unchecked" )
+ List<Object[]> results = query.list();
+
+ for( Object[] result : results ) {
+ s.delete( result[0] );
+ }
+ tx.commit();
+ s.close();
+ }
+
+
+ public void testIndexEmbedded() throws Exception{
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ ProductCatalog productCatalog = new ProductCatalog();
+ productCatalog.setName("Cars");
+ Item item = new Item();
+ item.setDescription("Ferrari");
+ item.setProductCatalog(productCatalog);
+ productCatalog.addItem(item);
+
+ s.persist(item);
+ s.persist(productCatalog);
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "items.description:Ferrari" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting 1 results", 1, query.getResultSize() );
+
+ @SuppressWarnings( "unchecked" )
+ List<Object[]> results = query.list();
+
+ for( Object[] result : results ) {
+ s.delete( result[0] );
+ }
+ tx.commit();
+ s.close();
+ }
+
+ public void testContainedIn() throws Exception{
+ FullTextSession s = Search.getFullTextSession( openSession() );
+ Transaction tx = s.beginTransaction();
+
+ ProductCatalog productCatalog = new ProductCatalog();
+ productCatalog.setName("Cars");
+ Item item = new Item();
+ item.setDescription("test");
+ item.setProductCatalog(productCatalog);
+ productCatalog.addItem(item);
+
+ s.persist(item);
+ s.persist(productCatalog);
+ tx.commit();
+
+ s.clear();
+
+ tx = s.beginTransaction();
+
+ QueryParser parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ org.apache.lucene.search.Query luceneQuery = parser.parse( "items.description:test" );
+ FullTextQuery query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting 1 results", 1, query.getResultSize() );
+ tx.commit();
+
+ tx = s.beginTransaction();
+
+ Item loaded = (Item) s.get(Item.class, item.getId());
+ loaded.setDescription("Ferrari");
+
+ s.update(loaded);
+ tx.commit();
+
+
+ tx = s.beginTransaction();
+
+ parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ luceneQuery = parser.parse( "items.description:test" );
+ query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting 0 results", 0, query.getResultSize() );
+
+ parser = new QueryParser( "id", new StandardAnalyzer( ) );
+ luceneQuery = parser.parse( "items.description:Ferrari" );
+ query = s.createFullTextQuery( luceneQuery ).setProjection( FullTextQuery.THIS, FullTextQuery.SCORE );
+ assertEquals( "expecting 1 results", 1, query.getResultSize() );
+ tx.commit();
+
+ tx = s.beginTransaction();
+ @SuppressWarnings( "unchecked" )
+ List<Object[]> results = query.list();
+
+ for( Object[] result : results ) {
+ s.delete( result[0] );
+ }
+ tx.commit();
+ s.close();
+ }
+
private int nbrOfMatchingResults(String field, String token, FullTextSession s) throws ParseException {
QueryParser parser = new QueryParser( field, new StandardAnalyzer() );
org.apache.lucene.search.Query luceneQuery = parser.parse( token );
@@ -225,6 +513,7 @@
super.configure( cfg );
//cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
SearchMapping mapping = new SearchMapping();
+
mapping.analyzerDef( "ngram", StandardTokenizerFactory.class )
.filter( LowerCaseFilterFactory.class )
.filter( NGramFilterFactory.class )
@@ -236,11 +525,21 @@
.analyzerDef( "de", StandardTokenizerFactory.class )
.filter( LowerCaseFilterFactory.class )
.filter( GermanStemFilterFactory.class )
-
- .indexedClass( Address.class )
+ .entity( Address.class ).indexed()
.similarity( DefaultSimilarity.class )
.boost( 2 )
+ .fullTextFilterDef("security", SecurityFilterFactory.class).cache(FilterCacheModeType.INSTANCE_ONLY)
.property( "addressId", ElementType.FIELD ).documentId().name( "id" )
+ .property("lastUpdated", ElementType.FIELD)
+ .field().name("last-updated")
+ .analyzer("en").store(Store.YES)
+ .calendarBridge(Resolution.DAY)
+ .property("dateCreated", ElementType.FIELD)
+ .field().name("date-created").index(Index.TOKENIZED)
+ .analyzer("en").store( Store.YES )
+ .dateBridge(Resolution.DAY)
+ .property("owner", ElementType.FIELD)
+ .field()
.property( "street1", ElementType.FIELD )
.field()
.field().name( "street1_ngram" ).analyzer( "ngram" )
@@ -249,14 +548,40 @@
.bridge( ConcatStringBridge.class ).param( ConcatStringBridge.SIZE, "4" )
.property( "street2", ElementType.METHOD )
.field().name( "idx_street2" ).store( Store.YES ).boost( 2 )
- .indexedClass( BlogEntry.class )
+ .entity(ProvidedIdEntry.class).indexed()
+ .providedId().name("providedidentry").bridge(LongBridge.class)
+ .property("name", ElementType.FIELD)
+ .field().name("providedidentry.name").analyzer("en").index(Index.TOKENIZED).store(Store.YES)
+ .property("blurb", ElementType.FIELD)
+ .field().name("providedidentry.blurb").analyzer("en").index(Index.TOKENIZED).store(Store.YES)
+ .property("age", ElementType.FIELD)
+ .field().name("providedidentry.age").analyzer("en").index(Index.TOKENIZED).store(Store.YES)
+ .entity(ProductCatalog.class).indexed()
+ .similarity( DefaultSimilarity.class )
+ .boost( 2 )
+ .property( "id", ElementType.FIELD ).documentId().name( "id" )
+ .property("name", ElementType.FIELD)
+ .field().name("productCatalogName").index(Index.TOKENIZED).analyzer("en").store(Store.YES)
+ .property("items", ElementType.FIELD)
+ .indexEmbedded()
+ .entity(Item.class)
+ .property("description", ElementType.FIELD)
+ .field().name("description").analyzer("en").index(Index.TOKENIZED).store(Store.YES)
+ .property("productCatalog", ElementType.FIELD)
+ .containedIn()
+ .entity( BlogEntry.class ).indexed()
.property( "title", ElementType.METHOD )
.field()
.property( "description", ElementType.METHOD )
.field()
.property( "language", ElementType.METHOD )
.analyzerDiscriminator(BlogEntry.BlogLangDiscriminator.class)
- ;
+ .property("dateCreated", ElementType.METHOD)
+ .field()
+ .name("blog-entry-created")
+ .analyzer("en")
+ .store(Store.YES)
+ .dateBridge(Resolution.DAY);
cfg.getProperties().put( "hibernate.search.mapping_model", mapping );
}
@@ -275,7 +600,7 @@
.filter( NGramFilterFactory.class)
.param("minGramSize", "3")
.param("maxGramSize", "3")
- .indexedClass(Address.class, "Address_Index")
+ .entity(Address.class).indexed().indexName("Address_Index")
.property("street1", ElementType.FIELD)
.field()
.field()
@@ -286,18 +611,22 @@
.field()
.name("street1_ngram")
.analyzer("ngram")
- .indexedClass(User.class)
+ .entity(User.class).indexed()
.property("name", ElementType.METHOD)
.field()
.analyzerDef( "minimal", StandardTokenizerFactory.class );
}
- protected Class[] getMappings() {
- return new Class[] {
+ protected Class<?>[] getMappings() {
+ return new Class<?>[] {
Address.class,
Country.class,
- BlogEntry.class
+ BlogEntry.class,
+ ProvidedIdEntry.class,
+ ProductCatalog.class,
+ Item.class
+
};
}
}
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/ProvidedIdEntry.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/ProvidedIdEntry.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/ProvidedIdEntry.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,46 @@
+package org.hibernate.search.test.configuration;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class ProvidedIdEntry implements Serializable {
+
+ private static final long serialVersionUID = 6756516458812576484L;
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ private String name;
+ private String blurb;
+ private int age;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getBlurb() {
+ return blurb;
+ }
+
+ public void setBlurb(String blurb) {
+ this.blurb = blurb;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+}
Added: search/trunk/src/test/java/org/hibernate/search/test/configuration/SecurityFilterFactory.java
===================================================================
--- search/trunk/src/test/java/org/hibernate/search/test/configuration/SecurityFilterFactory.java (rev 0)
+++ search/trunk/src/test/java/org/hibernate/search/test/configuration/SecurityFilterFactory.java 2009-11-20 14:01:40 UTC (rev 18015)
@@ -0,0 +1,60 @@
+package org.hibernate.search.test.configuration;
+
+import java.io.IOException;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.search.CachingWrapperFilter;
+import org.apache.lucene.search.DocIdSet;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.QueryWrapperFilter;
+import org.apache.lucene.util.OpenBitSet;
+import org.hibernate.search.annotations.Factory;
+import org.hibernate.search.annotations.Key;
+import org.hibernate.search.filter.FilterKey;
+import org.hibernate.search.filter.StandardFilterKey;
+
+public class SecurityFilterFactory {
+
+ private static final long serialVersionUID = -19238668272676998L;
+
+ private String ownerName;
+
+ public void setOwnerName(String ownerName) {
+ this.ownerName = ownerName;
+ }
+
+ @Factory
+ public Filter buildSecurityFilter() {
+ SecurityFilter securityFilter = new SecurityFilter(ownerName);
+ return new CachingWrapperFilter(securityFilter);
+ }
+
+ @Key
+ public FilterKey getKey() {
+ StandardFilterKey key = new StandardFilterKey();
+ key.addParameter(ownerName);
+ return key;
+ }
+
+ private final class SecurityFilter extends Filter {
+ private static final long serialVersionUID = -5105989141875576599L;
+ private final String ownerName;
+
+ private SecurityFilter(final String ownerName) {
+ this.ownerName = ownerName;
+ }
+
+ public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
+ OpenBitSet bitSet = new OpenBitSet( reader.maxDoc() );
+ TermDocs termDocs = reader.termDocs( new Term( "owner", ownerName ) );
+ while ( termDocs.next() ) {
+ bitSet.set( termDocs.doc() );
+ }
+ return bitSet;
+ }
+
+ }
+
+}
15 years