[hibernate-commits] Hibernate SVN: r20719 - in jpamodelgen/trunk/src: main/java/org/hibernate/jpamodelgen/util and 2 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Mon Sep 27 07:30:38 EDT 2010
Author: hardy.ferentschik
Date: 2010-09-27 07:30:37 -0400 (Mon, 27 Sep 2010)
New Revision: 20719
Added:
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java
jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java
Modified:
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java
Log:
METAGEN-38 Added support for Blob and a corresponding test.
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2010-09-26 19:56:28 UTC (rev 20718)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/annotation/AnnotationMetaEntity.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -413,7 +413,7 @@
return Boolean.TRUE;
}
- if ( ElementKind.CLASS.equals( element.getKind() ) ) {
+ if ( ElementKind.CLASS.equals( element.getKind() ) || ElementKind.INTERFACE.equals( element.getKind() )) {
TypeElement typeElement = ( ( TypeElement ) element );
String typeName = typeElement.getQualifiedName().toString();
if ( Constants.BASIC_TYPES.contains( typeName ) ) {
Modified: jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java
===================================================================
--- jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java 2010-09-26 19:56:28 UTC (rev 20718)
+++ jpamodelgen/trunk/src/main/java/org/hibernate/jpamodelgen/util/Constants.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
@@ -29,38 +29,41 @@
public static Map<String, String> COLLECTIONS = new HashMap<String, String>();
static {
- COLLECTIONS.put( "java.util.Collection", "javax.persistence.metamodel.CollectionAttribute" );
- COLLECTIONS.put( "java.util.Set", "javax.persistence.metamodel.SetAttribute" );
- COLLECTIONS.put( "java.util.List", "javax.persistence.metamodel.ListAttribute" );
- COLLECTIONS.put( "java.util.Map", "javax.persistence.metamodel.MapAttribute" );
+ COLLECTIONS.put(
+ java.util.Collection.class.getName(), javax.persistence.metamodel.CollectionAttribute.class.getName()
+ );
+ COLLECTIONS.put( java.util.Set.class.getName(), javax.persistence.metamodel.SetAttribute.class.getName() );
+ COLLECTIONS.put( java.util.List.class.getName(), javax.persistence.metamodel.ListAttribute.class.getName() );
+ COLLECTIONS.put( java.util.Map.class.getName(), javax.persistence.metamodel.MapAttribute.class.getName() );
}
public static List<String> BASIC_TYPES = new ArrayList<String>();
static {
- BASIC_TYPES.add( "java.lang.String" );
- BASIC_TYPES.add( "java.lang.Boolean" );
- BASIC_TYPES.add( "java.lang.Byte" );
- BASIC_TYPES.add( "java.lang.Character" );
- BASIC_TYPES.add( "java.lang.Short" );
- BASIC_TYPES.add( "java.lang.Integer" );
- BASIC_TYPES.add( "java.lang.Long" );
- BASIC_TYPES.add( "java.lang.Float" );
- BASIC_TYPES.add( "java.lang.Double" );
- BASIC_TYPES.add( "java.math.BigInteger" );
- BASIC_TYPES.add( "java.math.BigDecimal" );
- BASIC_TYPES.add( "java.util.Date" );
- BASIC_TYPES.add( "java.util.Calendar" );
- BASIC_TYPES.add( "java.sql.Date" );
- BASIC_TYPES.add( "java.sql.Time" );
- BASIC_TYPES.add( "java.sql.Timestamp" );
+ BASIC_TYPES.add( java.lang.String.class.getName() );
+ BASIC_TYPES.add( java.lang.Boolean.class.getName() );
+ BASIC_TYPES.add( java.lang.Byte.class.getName() );
+ BASIC_TYPES.add( java.lang.Character.class.getName() );
+ BASIC_TYPES.add( java.lang.Short.class.getName() );
+ BASIC_TYPES.add( java.lang.Integer.class.getName() );
+ BASIC_TYPES.add( java.lang.Long.class.getName() );
+ BASIC_TYPES.add( java.lang.Float.class.getName() );
+ BASIC_TYPES.add( java.lang.Double.class.getName() );
+ BASIC_TYPES.add( java.math.BigInteger.class.getName() );
+ BASIC_TYPES.add( java.math.BigDecimal.class.getName() );
+ BASIC_TYPES.add( java.util.Date.class.getName() );
+ BASIC_TYPES.add( java.util.Calendar.class.getName() );
+ BASIC_TYPES.add( java.sql.Date.class.getName() );
+ BASIC_TYPES.add( java.sql.Time.class.getName() );
+ BASIC_TYPES.add( java.sql.Timestamp.class.getName() );
+ BASIC_TYPES.add( java.sql.Blob.class.getName() );
}
public static List<String> BASIC_ARRAY_TYPES = new ArrayList<String>();
static {
- BASIC_ARRAY_TYPES.add( "java.lang.Character" );
- BASIC_ARRAY_TYPES.add( "java.lang.Byte" );
+ BASIC_ARRAY_TYPES.add( java.lang.Character.class.getName() );
+ BASIC_ARRAY_TYPES.add( java.lang.Byte.class.getName() );
}
public static final String PATH_SEPARATOR = "/";
Added: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobEntity.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -0,0 +1,39 @@
+// $Id: User.java 17903 2009-11-04 13:22:37Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.blob;
+
+import java.sql.Blob;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+/**
+ * @author Hardy Ferentschik
+ */
+ at Entity
+ at Table
+public class BlobEntity {
+ @Id
+ private String id;
+
+ @Lob
+ private Blob blob;
+}
+
+
Copied: jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java (from rev 20692, jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/elementcollection/ElementCollectionTest.java)
===================================================================
--- jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java (rev 0)
+++ jpamodelgen/trunk/src/test/java/org/hibernate/jpamodelgen/test/blob/BlobTest.java 2010-09-27 11:30:37 UTC (rev 20719)
@@ -0,0 +1,44 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jpamodelgen.test.blob;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class BlobTest extends CompilationTest {
+ /**
+ * METAGEN-38
+ */
+ @Test
+ public void testBlobField() {
+ assertMetamodelClassGeneratedFor( BlobEntity.class );
+ assertPresenceOfFieldInMetamodelFor( BlobEntity.class, "blob", "the metamodel should have a member 'blob'" );
+ }
+
+ @Override
+ protected String getPackageNameOfTestSources() {
+ return BlobTest.class.getPackage().getName();
+ }
+}
\ No newline at end of file
More information about the hibernate-commits
mailing list