Author: hardy.ferentschik
Date: 2010-01-12 13:50:42 -0500 (Tue, 12 Jan 2010)
New Revision: 18519
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Cook.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Knive.java
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Cook.xml
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/XmlAccessTest.java
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Crew.xml
Log:
HHH-4691 - xml access type support for embedded-id and embedded
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java
===================================================================
---
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java 2010-01-12
18:48:42 UTC (rev 18518)
+++
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverridenAnnotationReader.java 2010-01-12
18:50:42 UTC (rev 18519)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@@ -839,6 +839,7 @@
if ( "embedded".equals( element.getName() ) ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Embedded.class );
annotationList.add( AnnotationFactory.create( ad ) );
+ getAccessType( annotationList, element );
}
}
if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
@@ -985,6 +986,7 @@
addIfNotNull( annotationList, annotation );
AnnotationDescriptor ad = new AnnotationDescriptor( EmbeddedId.class );
annotationList.add( AnnotationFactory.create( ad ) );
+ getAccessType( annotationList, element );
}
}
}
Copied:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Cook.java
(from rev 18515,
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Waiter.java)
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Cook.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Cook.java 2010-01-12
18:50:42 UTC (rev 18519)
@@ -0,0 +1,51 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.test.annotations.access.xml;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Cook {
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private Knive favouriteKnife;
+
+ public Knive getFavouriteKnife() {
+ return favouriteKnife;
+ }
+
+ public void setFavouriteKnife(Knive favouriteKnife) {
+ this.favouriteKnife = favouriteKnife;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+}
\ No newline at end of file
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Knive.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Knive.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/Knive.java 2010-01-12
18:50:42 UTC (rev 18519)
@@ -0,0 +1,46 @@
+// $Id: Waiter.java 18506 2010-01-11 20:23:08Z hardy.ferentschik $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.test.annotations.access.xml;
+
+import javax.persistence.Embeddable;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Embeddable
+public class Knive {
+ private String brand;
+
+ private int bladeLength;
+
+ public int getBladeLength() {
+ return bladeLength;
+ }
+
+ public void setBladeLength(int bladeLength) {
+ this.bladeLength = bladeLength;
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+}
\ No newline at end of file
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/XmlAccessTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/XmlAccessTest.java 2010-01-12
18:48:42 UTC (rev 18518)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/access/xml/XmlAccessTest.java 2010-01-12
18:50:42 UTC (rev 18519)
@@ -60,7 +60,7 @@
// now with an additional xml configuration file changing the default access type for
Tourist using basic
configFiles = new ArrayList<String>();
- configFiles.add("org/hibernate/test/annotations/access/xml/Tourist.xml");
+ configFiles.add( "org/hibernate/test/annotations/access/xml/Tourist.xml" );
factory = buildSessionFactory( classes, configFiles );
assertAccessType( factory, classUnderTest, AccessType.PROPERTY );
}
@@ -120,7 +120,7 @@
Class<?> classUnderTest = Waiter.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add( classUnderTest );
- classes.add(Crew.class);
+ classes.add( Crew.class );
List<String> configFiles = new ArrayList<String>();
configFiles.add( "org/hibernate/test/annotations/access/xml/Crew.xml" );
SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles );
@@ -131,13 +131,24 @@
Class<?> classUnderTest = RentalCar.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add( classUnderTest );
- classes.add(Driver.class);
+ classes.add( Driver.class );
List<String> configFiles = new ArrayList<String>();
configFiles.add( "org/hibernate/test/annotations/access/xml/RentalCar.xml"
);
SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles );
assertAccessType( factory, classUnderTest, AccessType.PROPERTY );
}
+ public void testAccessOnEmbeddedXmlElement() throws Exception {
+ Class<?> classUnderTest = Cook.class;
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.add( classUnderTest );
+ classes.add( Knive.class );
+ List<String> configFiles = new ArrayList<String>();
+ configFiles.add( "org/hibernate/test/annotations/access/xml/Cook.xml" );
+ SessionFactoryImplementor factory = buildSessionFactory( classes, configFiles );
+ assertAccessType( factory, classUnderTest, AccessType.PROPERTY );
+ }
+
private SessionFactoryImplementor buildSessionFactory(List<Class<?>>
classesUnderTest, List<String> configFiles) {
assert classesUnderTest != null;
assert configFiles != null;
@@ -153,6 +164,7 @@
}
// uses the first getter of the tupelizer for the assertions
+
private void assertAccessType(SessionFactoryImplementor factory, Class<?>
classUnderTest, AccessType accessType) {
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
.getEntityMetamodel();
Copied:
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Cook.xml
(from rev 18515,
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Crew.xml)
===================================================================
---
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Cook.xml
(rev 0)
+++
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Cook.xml 2010-01-12
18:50:42 UTC (rev 18519)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
file:/Users/hardy/work/hibernate/core/trunk/annotations/src/main/resources/org/hibernate/ejb/orm_2_0.xsd"
+ version="2.0">
+ <package>org.hibernate.test.annotations.access.xml</package>
+ <entity class="Cook" metadata-complete="false">
+ <attributes>
+ <embedded name="favouriteKnife"
access="PROPERTY"/>
+ </attributes>
+ </entity>
+</entity-mappings>
Modified:
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Crew.xml
===================================================================
---
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Crew.xml 2010-01-12
18:48:42 UTC (rev 18518)
+++
core/trunk/annotations/src/test/resources/org/hibernate/test/annotations/access/xml/Crew.xml 2010-01-12
18:50:42 UTC (rev 18519)
@@ -3,7 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
file:/Users/hardy/work/hibernate/core/trunk/annotations/src/main/resources/org/hibernate/ejb/orm_2_0.xsd"
version="2.0">
- <description>Mapping for Crew entity</description>
<package>org.hibernate.test.annotations.access.xml</package>
<mapped-superclass class="Crew" metadata-complete="false"
access="FIELD">
<attributes>