Hibernate SVN: r17846 - in core/trunk/annotations: src/main/docbook/en/images and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-27 05:36:55 -0400 (Tue, 27 Oct 2009)
New Revision: 17846
Removed:
core/trunk/annotations/src/main/docbook/en/images/hibernate_logo_a.png
core/trunk/annotations/src/main/docbook/fr/images/hibernate_logo_a.png
core/trunk/annotations/src/main/docbook/zh_cn/images/hibernate_logo_a.png
Modified:
core/trunk/annotations/pom.xml
Log:
HHH-4530
Modified: core/trunk/annotations/pom.xml
===================================================================
--- core/trunk/annotations/pom.xml 2009-10-26 18:35:29 UTC (rev 17845)
+++ core/trunk/annotations/pom.xml 2009-10-27 09:36:55 UTC (rev 17846)
@@ -163,47 +163,52 @@
<id>doc</id>
<build>
<plugins>
- <plugin>
+ <plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
- <version>2.1.0</version>
+ <version>2.2.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jdocbook-style</artifactId>
- <version>1.0.2</version>
+ <version>2.0.0</version>
<type>jdocbook-style</type>
</dependency>
</dependencies>
<configuration>
<sourceDocumentName>master.xml</sourceDocumentName>
- <sourceDirectory>${basedir}/src/main/docbook/en</sourceDirectory>
- <masterTranslation>en-US</masterTranslation>
+ <sourceDirectory>${basedir}/src/main/docbook</sourceDirectory>
+ <masterTranslation>en</masterTranslation>
<imageResource>
<directory>${basedir}/src/main/docbook/en/images</directory>
</imageResource>
<formats>
<format>
<formatName>pdf</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/pdf/main-pdf.xsl</stylesheetResource>
- <finalName>hibernate-validator-legacy-guide.pdf</finalName>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/pdf.xsl</stylesheetResource>
+ <finalName>hibernate_reference.pdf</finalName>
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-single.xsl </stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl
+ </stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-chunk.xsl </stylesheetResource>
+ <stylesheetResource>classpath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl
+ </stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
<options>
<xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <!-- needed for uri-resolvers; can be ommitted if using 'current' uri scheme -->
+ <!-- could also locate the docbook dependency and inspect its version... -->
+ <docbookVersion>1.72.0</docbookVersion>
<localeSeparator>-</localeSeparator>
- <useRelativeImageUris>true</useRelativeImageUris>
</options>
</configuration>
<executions>
Deleted: core/trunk/annotations/src/main/docbook/en/images/hibernate_logo_a.png
===================================================================
(Binary files differ)
Deleted: core/trunk/annotations/src/main/docbook/fr/images/hibernate_logo_a.png
===================================================================
(Binary files differ)
Deleted: core/trunk/annotations/src/main/docbook/zh_cn/images/hibernate_logo_a.png
===================================================================
(Binary files differ)
14 years, 6 months
Hibernate SVN: r17845 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/criteria and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-26 14:35:29 -0400 (Mon, 26 Oct 2009)
New Revision: 17845
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
Log:
HHH-4203 - Implement JPA 2.0 criteria apis (compiling)
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java 2009-10-26 17:08:09 UTC (rev 17844)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -26,6 +26,8 @@
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.ManagedType;
+
import org.hibernate.ejb.criteria.JoinImplementors.CollectionJoinImplementor;
/**
@@ -58,6 +60,12 @@
}
@Override
+ protected ManagedType<E> getManagedType() {
+ return ( ManagedType<E> ) getAttribute().getElementType();
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked" })
public CollectionJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
CollectionJoinImpl<O,E> correlation = new CollectionJoinImpl<O,E>(
queryBuilder(),
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java 2009-10-26 17:08:09 UTC (rev 17844)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -56,12 +56,17 @@
javaType,
lhs,
joinProperty,
- (ManagedType<X>) criteriaBuilder.getEntityManagerFactory().getMetamodel().managedType( javaType )
+ criteriaBuilder.getEntityManagerFactory().getMetamodel().managedType( javaType )
);
- this.managedType = (ManagedType<X>) getModel();
+ this.managedType = getManagedType();
this.joinType = joinType;
}
+ @SuppressWarnings({ "unchecked" })
+ protected ManagedType<X> getManagedType() {
+ return (ManagedType<X>) getModel();
+ }
+
/**
* {@inheritDoc}
*/
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java 2009-10-26 17:08:09 UTC (rev 17844)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -27,6 +27,8 @@
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.ManagedType;
+
import org.hibernate.ejb.criteria.JoinImplementors.ListJoinImplementor;
import org.hibernate.ejb.criteria.expression.ListIndexExpression;
@@ -53,9 +55,14 @@
@Override
public ListAttribute<? super O, E> getModel() {
- return (ListAttribute<? super O, E>) getAttribute();
+ return getAttribute();
}
+ @Override
+ protected ManagedType<E> getManagedType() {
+ return ( ManagedType<E> ) getAttribute().getElementType();
+ }
+
/**
* {@inheritDoc}
*/
@@ -64,6 +71,7 @@
}
@Override
+ @SuppressWarnings({ "unchecked" })
public ListJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
ListJoinImpl<O,E> correlation = new ListJoinImpl<O,E>(
queryBuilder(),
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java 2009-10-26 17:08:09 UTC (rev 17844)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -31,6 +31,7 @@
import javax.persistence.criteria.Path;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.Type.PersistenceType;
import org.hibernate.ejb.criteria.JoinImplementors.MapJoinImplementor;
@@ -63,6 +64,11 @@
return getAttribute();
}
+ @Override
+ protected ManagedType<V> getManagedType() {
+ return ( ManagedType<V> ) getAttribute().getElementType();
+ }
+
/**
* {@inheritDoc}
*/
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2009-10-26 17:08:09 UTC (rev 17844)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -214,11 +214,10 @@
if ( getSelection() == null ) {
// we should have only a single root (query validation should have checked this...)
final Root root = getRoots().iterator().next();
- ( (TableExpressionMapper) root ).prepareAlias( renderingContext );
- jpaqlQuery.append( root.getAlias() );
+ jpaqlQuery.append( ( (ExpressionImplementor) root ).renderProjection( renderingContext) );
}
else {
- ( ( ExpressionImplementor ) getSelection() ).renderProjection( renderingContext );
+ jpaqlQuery.append( ( (ExpressionImplementor) getSelection() ).renderProjection( renderingContext ) );
}
jpaqlQuery.append( " from " );
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java 2009-10-26 17:08:09 UTC (rev 17844)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -26,6 +26,8 @@
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute;
+import javax.persistence.metamodel.ManagedType;
+
import org.hibernate.ejb.criteria.JoinImplementors.SetJoinImplementor;
/**
@@ -58,6 +60,12 @@
}
@Override
+ protected ManagedType<E> getManagedType() {
+ return ( ManagedType<E> ) getAttribute().getElementType();
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked" })
public SetJoinImplementor<O, E> correlateTo(CriteriaSubqueryImpl subquery) {
SetJoinImpl<O,E> correlation = new SetJoinImpl<O,E>(
queryBuilder(),
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -0,0 +1,97 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * 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.ejb.criteria;
+
+import javax.persistence.EntityManager;
+import javax.persistence.criteria.Root;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Join;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class CriteriaCompilingTest extends TestCase {
+ public Class[] getAnnotatedClasses() {
+ return new Class[] {
+ Customer.class,
+ Item.class,
+ Order.class,
+ Product.class
+ };
+ }
+
+ public void testJustSimpleRootCriteria() {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+
+ // First w/o explicit selection...
+ CriteriaQuery<Customer> criteria = em.getCriteriaBuilder().createQuery( Customer.class );
+ criteria.from( Customer.class );
+ em.createQuery( criteria ).getResultList();
+
+ // Now with...
+ criteria = em.getCriteriaBuilder().createQuery( Customer.class );
+ Root<Customer> root = criteria.from( Customer.class );
+ criteria.select( root );
+ em.createQuery( criteria ).getResultList();
+
+ em.getTransaction().commit();
+ em.close();
+ }
+
+ public void testSimpleJoinCriteria() {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+
+ // String based...
+ CriteriaQuery<Order> criteria = em.getCriteriaBuilder().createQuery( Order.class );
+ Root<Order> root = criteria.from( Order.class );
+ root.join( "lineItems" );
+ criteria.select( root );
+ em.createQuery( criteria ).getResultList();
+
+ em.getTransaction().commit();
+ em.close();
+ }
+
+ public void testSimpleFetchCriteria() {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+
+ // String based...
+ CriteriaQuery<Order> criteria = em.getCriteriaBuilder().createQuery( Order.class );
+ Root<Order> root = criteria.from( Order.class );
+ root.fetch( "lineItems" );
+ criteria.select( root );
+ em.createQuery( criteria ).getResultList();
+
+ em.getTransaction().commit();
+ em.close();
+ }
+
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -0,0 +1,79 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * 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.ejb.criteria;
+
+import java.util.Set;
+import java.util.HashSet;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.OneToMany;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+@Entity
+public class Customer {
+ private Long id;
+ private String name;
+ private int status;
+ private Set<Order> orders = new HashSet<Order>();
+
+ @Id
+ @GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ void setId(Long id) {
+ this.id = id;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @OneToMany( mappedBy = "customer" )
+ public Set<Order> getOrders() {
+ return orders;
+ }
+
+ void setOrders(Set<Order> orders) {
+ this.orders = orders;
+ }
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -0,0 +1,78 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * 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.ejb.criteria;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.ManyToOne;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+@Entity
+public class Item {
+ private Long id;
+ private Order order;
+ private Product product;
+ private long quantity;
+
+ @Id
+ @GeneratedValue
+ Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @ManyToOne
+ public Order getOrder() {
+ return order;
+ }
+
+ public void setOrder(Order order) {
+ this.order = order;
+ }
+
+ @ManyToOne
+ public Product getProduct() {
+ return product;
+ }
+
+ public void setProduct(Product product) {
+ this.product = product;
+ }
+
+ public long getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(long quantity) {
+ this.quantity = quantity;
+ }
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -0,0 +1,84 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * 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.ejb.criteria;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.OneToMany;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+@Entity
+@Table( name="t_order" )
+public class Order {
+ private Long id;
+ private Customer customer;
+ private Date date;
+ private Set<Item> lineItems = new HashSet<Item>();
+
+ @Id
+ @GeneratedValue
+ Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @ManyToOne
+ public Customer getCustomer() {
+ return customer;
+ }
+
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ @OneToMany( mappedBy = "order" )
+ public Set<Item> getLineItems() {
+ return lineItems;
+ }
+
+ void setLineItems(Set<Item> lineItems) {
+ this.lineItems = lineItems;
+ }
+}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java 2009-10-26 18:35:29 UTC (rev 17845)
@@ -0,0 +1,80 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * 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.ejb.criteria;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+(a)javax.persistence.Entity
+public class Product {
+ private Long id;
+ private String name;
+ private String manufacturer;
+ private String model;
+ private String productType;
+
+ @javax.persistence.Id
+ @javax.persistence.GeneratedValue
+ public Long getId() {
+ return id;
+ }
+
+ void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getManufacturer() {
+ return manufacturer;
+ }
+
+ public void setManufacturer(String manufacturer) {
+ this.manufacturer = manufacturer;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public String getProductType() {
+ return productType;
+ }
+
+ public void setProductType(String productType) {
+ this.productType = productType;
+ }
+}
14 years, 6 months
Hibernate SVN: r17844 - validator/trunk/hibernate-validator/src/main/docbook/en-US/modules.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-26 13:08:09 -0400 (Mon, 26 Oct 2009)
New Revision: 17844
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
Log:
HV-259
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-10-26 17:04:59 UTC (rev 17843)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-10-26 17:08:09 UTC (rev 17844)
@@ -141,14 +141,36 @@
<para>an attribute <classname>payload</classname> that can be used
by clients of the Bean Validation API to asign custom payload
objects to a constraint. This attribute is not used by the API
- itself.</para>
+ itself. <tip>
+ <para>An examle for a custom payload could be the definition of
+ a severity. <programlisting>public class Severity {
+ public static class Info extends ConstraintPayload {};
+ public static class Error extends ConstraintPayload {};
+}
+
+public class ContactDetails {
+ @NotNull(message="Name is mandatory", payload=Severity.Error.class)
+ private String name;
+
+ @NotNull(message="Phone number not specified, but not mandatory", payload=Severity.Info.class)
+ private String phoneNumber;
+
+ // ...
+}</programlisting>Now a client can after the validation of a
+ <classname>ContactDetails</classname> instance access the
+ severity of a constraint using
+ <methodname>ConstraintViolation.getConstraintDescriptor().getPayload()</methodname>
+ and adjust its behaviour depending on the severity.</para>
+ </tip></para>
</listitem>
</itemizedlist>
- <para>Besides those three mandatory attributes we add another one
- allowing for the required case mode to be specified. The name
- <property>value</property> is a special one, which can be omitted upon
- using the annotation, if it is the only attribute specified, as e.g. in
+ <para>Besides those three mandatory attributes
+ (<property>messge</property>, <property>groups</property> and
+ <property>payload</property>) we add another one allowing for the
+ required case mode to be specified. The name <property>value</property>
+ is a special one, which can be omitted upon using the annotation, if it
+ is the only attribute specified, as e.g. in
<code>@CheckCase(CaseMode.UPPER)</code>.</para>
<para>In addition we annotate the annotation type with a couple of
14 years, 6 months
Hibernate SVN: r17843 - in core/trunk: core/src/main/java/org/hibernate/tuple and 6 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-26 13:04:59 -0400 (Mon, 26 Oct 2009)
New Revision: 17843
Modified:
core/trunk/core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/ChainedPropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/Dom4jAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/Getter.java
core/trunk/core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/MapAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/NoopAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessor.java
core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessorFactory.java
core/trunk/core/src/main/java/org/hibernate/property/Setter.java
core/trunk/core/src/main/java/org/hibernate/property/package.html
core/trunk/core/src/main/java/org/hibernate/tuple/Tuplizer.java
core/trunk/core/src/main/java/org/hibernate/tuple/component/AbstractComponentTuplizer.java
core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java
core/trunk/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java
core/trunk/core/src/main/java/org/hibernate/tuple/entity/EntityTuplizer.java
core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java
core/trunk/core/src/main/java/org/hibernate/type/ComponentType.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AbstractIdentifiableType.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/EmbeddableTypeImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetamodelImpl.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
Log:
HHH-4202 - Implement JPA 2.0 metamodel APIs
Modified: core/trunk/core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,12 +20,12 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.io.Serializable;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -143,6 +143,13 @@
/**
* {@inheritDoc}
*/
+ public Member getMember() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object target) {
return UNKNOWN;
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,13 +20,13 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.beans.Introspector;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.slf4j.Logger;
@@ -164,6 +164,9 @@
this.propertyName=propertyName;
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object target) throws HibernateException {
try {
return method.invoke(target, null);
@@ -202,18 +205,37 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
return get( target );
}
+ /**
+ * {@inheritDoc}
+ */
public Class getReturnType() {
return method.getReturnType();
}
+ /**
+ * {@inheritDoc}
+ */
+ public Member getMember() {
+ return method;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return method;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return method.getName();
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/ChainedPropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/ChainedPropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/ChainedPropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
Modified: core/trunk/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,12 +20,12 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.HibernateException;
@@ -50,6 +50,10 @@
this.clazz = clazz;
this.name = name;
}
+
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object target) throws HibernateException {
try {
return field.get(target);
@@ -59,16 +63,37 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
return get( target );
}
+ /**
+ * {@inheritDoc}
+ */
+ public Member getMember() {
+ return field;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ */
public Class getReturnType() {
return field.getType();
}
@@ -91,12 +116,24 @@
this.clazz = clazz;
this.name = name;
}
+
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ */
public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {
try {
field.set(target, value);
Modified: core/trunk/core/src/main/java/org/hibernate/property/Dom4jAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/Dom4jAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/Dom4jAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,11 +20,11 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.dom4j.Attribute;
@@ -53,7 +53,6 @@
this.factory = factory;
this.nodeName = nodeName;
this.propertyType = propertyType;
-
}
/**
@@ -118,21 +117,28 @@
}
/**
- * Get the declared Java type
+ * {@inheritDoc}
*/
public Class getReturnType() {
return Object.class;
}
/**
- * Optional operation (return null)
+ * {@inheritDoc}
*/
+ public Member getMember() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
/**
- * Optional operation (return null)
+ * {@inheritDoc}
*/
public Method getMethod() {
return null;
@@ -147,14 +153,14 @@
}
/**
- * Optional operation (return null)
+ * {@inheritDoc}
*/
public String getMethodName() {
return null;
}
/**
- * Optional operation (return null)
+ * {@inheritDoc}
*/
public Method getMethod() {
return null;
@@ -166,16 +172,17 @@
* @author Gavin King
*/
public static class TextGetter extends Dom4jGetter {
-
TextGetter(Type propertyType, SessionFactoryImplementor factory) {
super(propertyType, factory);
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object owner) throws HibernateException {
Element ownerElement = (Element) owner;
return super.propertyType.fromXMLNode(ownerElement, super.factory);
}
-
}
/**
@@ -184,19 +191,21 @@
*/
public static class AttributeGetter extends Dom4jGetter {
private final String attributeName;
-
+
AttributeGetter(String name, Type propertyType, SessionFactoryImplementor factory) {
super(propertyType, factory);
attributeName = name.substring(1);
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object owner) throws HibernateException {
Element ownerElement = (Element) owner;
Node attribute = ownerElement.attribute(attributeName);
return attribute==null ? null :
super.propertyType.fromXMLNode(attribute, super.factory);
}
-
}
/**
@@ -211,13 +220,15 @@
elementName = name;
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object owner) throws HibernateException {
Element ownerElement = (Element) owner;
Node element = ownerElement.element(elementName);
return element==null ?
null : super.propertyType.fromXMLNode(element, super.factory);
}
-
}
/**
@@ -227,13 +238,16 @@
public static class ElementAttributeGetter extends Dom4jGetter {
private final String elementName;
private final String attributeName;
-
+
ElementAttributeGetter(String name, Type propertyType, SessionFactoryImplementor factory) {
super(propertyType, factory);
elementName = name.substring( 0, name.indexOf('/') );
attributeName = name.substring( name.indexOf('/')+2 );
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object owner) throws HibernateException {
Element ownerElement = (Element) owner;
@@ -260,12 +274,14 @@
* @author Gavin King
*/
public static class TextSetter extends Dom4jSetter {
-
TextSetter(Type propertyType) {
super(propertyType);
}
- public void set(Object target, Object value, SessionFactoryImplementor factory)
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor factory)
throws HibernateException {
Element owner = ( Element ) target;
if ( !super.propertyType.isXMLElement() ) { //kinda ugly, but needed for collections with a "." node mapping
@@ -277,7 +293,6 @@
}
}
}
-
}
/**
@@ -286,13 +301,16 @@
*/
public static class AttributeSetter extends Dom4jSetter {
private final String attributeName;
-
+
AttributeSetter(String name, Type propertyType) {
super(propertyType);
attributeName = name.substring(1);
}
- public void set(Object target, Object value, SessionFactoryImplementor factory)
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor factory)
throws HibernateException {
Element owner = ( Element ) target;
Attribute attribute = owner.attribute(attributeName);
@@ -307,7 +325,6 @@
super.propertyType.setToXMLNode(attribute, value, factory);
}
}
-
}
/**
@@ -322,7 +339,10 @@
elementName = name;
}
- public void set(Object target, Object value, SessionFactoryImplementor factory)
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor factory)
throws HibernateException {
if (value!=CollectionType.UNFETCHED_COLLECTION) {
Element owner = ( Element ) target;
@@ -334,7 +354,6 @@
}
}
}
-
}
/**
@@ -351,7 +370,10 @@
attributeName = name.substring( name.indexOf('/')+2 );
}
- public void set(Object target, Object value, SessionFactoryImplementor factory)
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor factory)
throws HibernateException {
Element owner = ( Element ) target;
Element element = owner.element(elementName);
@@ -375,7 +397,6 @@
super.propertyType.setToXMLNode(attribute, value, factory);
}
}
-
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,11 +20,11 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.HibernateException;
@@ -38,29 +38,50 @@
public class EmbeddedPropertyAccessor implements PropertyAccessor {
public static final class EmbeddedGetter implements Getter {
-
private final Class clazz;
EmbeddedGetter(Class clazz) {
this.clazz = clazz;
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object target) throws HibernateException {
return target;
}
+ /**
+ * {@inheritDoc}
+ */
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
return get( target );
}
+ /**
+ * {@inheritDoc}
+ */
+ public Member getMember() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Class getReturnType() {
return clazz;
}
@@ -71,23 +92,35 @@
}
public static final class EmbeddedSetter implements Setter {
-
private final Class clazz;
EmbeddedSetter(Class clazz) {
this.clazz = clazz;
}
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {}
-
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor factory) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String toString() {
return "EmbeddedSetter(" + clazz.getName() + ')';
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/Getter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/Getter.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/Getter.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,12 +20,12 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.io.Serializable;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.HibernateException;
@@ -58,17 +58,35 @@
throws HibernateException;
/**
- * Get the declared Java type
+ * Retrieve the member to which this property maps. This might be the
+ * field or it might be the getter method.
+ *
+ * @return The mapped member.
*/
+ public Member getMember();
+
+ /**
+ * Retrieve the declared Java type
+ *
+ * @return The declared java type.
+ */
public Class getReturnType();
/**
+ * Retrieve the getter-method name.
+ * <p/>
* Optional operation (return null)
+ *
+ * @return The name of the getter method, or null.
*/
public String getMethodName();
/**
+ * Retrieve the getter-method.
+ * <p/>
* Optional operation (return null)
+ *
+ * @return The getter method, or null.
*/
public Method getMethod();
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,11 +20,11 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.HibernateException;
@@ -37,7 +37,6 @@
* @author Gavin King
*/
public class IndexPropertyAccessor implements PropertyAccessor {
-
private final String propertyName;
private final String entityName;
@@ -45,6 +44,7 @@
* Constructs a new instance of IndexPropertyAccessor.
*
* @param collectionRole The collection role which this back ref references.
+ * @param entityName The name of the entity owning the collection.
*/
public IndexPropertyAccessor(String collectionRole, String entityName) {
this.propertyName = collectionRole.substring( entityName.length()+1 );
@@ -64,23 +64,27 @@
* The Setter implementation for index backrefs.
*/
public static final class IndexSetter implements Setter {
-
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
- public void set(Object target, Object value) {
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor factory) {
// do nothing...
}
- public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException {
- // do nothing...
- }
-
}
@@ -88,7 +92,6 @@
* The Getter implementation for index backrefs.
*/
public class IndexGetter implements Getter {
-
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException {
if (session==null) {
return BackrefPropertyAccessor.UNKNOWN;
@@ -99,18 +102,37 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object target) {
return BackrefPropertyAccessor.UNKNOWN;
}
+ /**
+ * {@inheritDoc}
+ */
+ public Member getMember() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Class getReturnType() {
return Object.class;
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/MapAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/MapAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/MapAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,11 +20,11 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.HibernateException;
@@ -36,33 +36,46 @@
* @author Gavin King
*/
public class MapAccessor implements PropertyAccessor {
-
+ /**
+ * {@inheritDoc}
+ */
public Getter getGetter(Class theClass, String propertyName)
throws PropertyNotFoundException {
return new MapGetter(propertyName);
}
+ /**
+ * {@inheritDoc}
+ */
public Setter getSetter(Class theClass, String propertyName)
throws PropertyNotFoundException {
return new MapSetter(propertyName);
}
public static final class MapSetter implements Setter {
-
private String name;
MapSetter(String name) {
this.name = name;
}
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public void set(Object target, Object value, SessionFactoryImplementor factory)
throws HibernateException {
( (Map) target ).put(name, value);
@@ -71,33 +84,53 @@
}
public static final class MapGetter implements Getter {
-
private String name;
MapGetter(String name) {
this.name = name;
}
+ /**
+ * {@inheritDoc}
+ */
+ public Member getMember() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Object get(Object target) throws HibernateException {
return ( (Map) target ).get(name);
}
+ /**
+ * {@inheritDoc}
+ */
public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) {
return get( target );
}
+ /**
+ * {@inheritDoc}
+ */
public Class getReturnType() {
return Object.class;
}
-
}
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/NoopAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/NoopAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/NoopAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,11 +20,11 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
import java.lang.reflect.Method;
+import java.lang.reflect.Member;
import java.util.Map;
import org.hibernate.HibernateException;
@@ -38,11 +38,16 @@
* @author Michael Bartmann
*/
public class NoopAccessor implements PropertyAccessor {
-
+ /**
+ * {@inheritDoc}
+ */
public Getter getGetter(Class arg0, String arg1) throws PropertyNotFoundException {
return new NoopGetter();
}
+ /**
+ * {@inheritDoc}
+ */
public Setter getSetter(Class arg0, String arg1) throws PropertyNotFoundException {
return new NoopSetter();
}
@@ -51,47 +56,73 @@
* A Getter which will always return null. It should not be called anyway.
*/
private static class NoopGetter implements Getter {
-
/**
- * @return always null
+ * {@inheritDoc}
+ * <p/>
+ * Here we always return <tt>null</tt>
*/
public Object get(Object target) throws HibernateException {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Object getForInsert(Object target, Map map, SessionImplementor arg1)
throws HibernateException {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Class getReturnType() {
return Object.class;
}
+ /**
+ * {@inheritDoc}
+ */
+ public Member getMember() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
-
}
/**
* A Setter which will just do nothing.
*/
private static class NoopSetter implements Setter {
-
- public void set(Object target, Object value, SessionFactoryImplementor arg2)
- throws HibernateException {
- // do not do anything
+ /**
+ * {@inheritDoc}
+ */
+ public void set(Object target, Object value, SessionFactoryImplementor arg2) {
+ // nothing to do
}
+ /**
+ * {@inheritDoc}
+ */
public String getMethodName() {
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Method getMethod() {
return null;
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessor.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessor.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
@@ -29,15 +28,31 @@
/**
* Abstracts the notion of a "property". Defines a strategy for accessing the
* value of an attribute.
+ *
* @author Gavin King
*/
public interface PropertyAccessor {
/**
* Create a "getter" for the named attribute
+ *
+ * @param theClass The class on which the property is defined.
+ * @param propertyName The name of the property.
+ *
+ * @return An appropriate getter.
+ *
+ * @throws PropertyNotFoundException Indicates a problem interpretting the propertyName
*/
public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException;
+
/**
* Create a "setter" for the named attribute
+ *
+ * @param theClass The class on which the property is defined.
+ * @param propertyName The name of the property.
+ *
+ * @return An appropriate setter
+ *
+ * @throws PropertyNotFoundException Indicates a problem interpretting the propertyName
*/
public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException;
}
Modified: core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessorFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessorFactory.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/PropertyAccessorFactory.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
Modified: core/trunk/core/src/main/java/org/hibernate/property/Setter.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/Setter.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/Setter.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
- * Copyright (c) 2008, 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.
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
*
* 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
@@ -20,7 +20,6 @@
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
- *
*/
package org.hibernate.property;
Modified: core/trunk/core/src/main/java/org/hibernate/property/package.html
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/property/package.html 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/property/package.html 2009-10-26 17:04:59 UTC (rev 17843)
@@ -1,10 +1,10 @@
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
- ~ Copyright (c) 2008, 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.
+ ~ Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ ~ third-party contributors as indicated by either @author tags or express
+ ~ copyright attribution statements applied by the authors. All
+ ~ third-party contributions are distributed under license by Red Hat Inc.
~
~ 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
@@ -20,7 +20,6 @@
~ Free Software Foundation, Inc.
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
- ~
-->
<html>
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/Tuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/Tuplizer.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/Tuplizer.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -25,6 +25,7 @@
package org.hibernate.tuple;
import org.hibernate.HibernateException;
+import org.hibernate.property.Getter;
/**
* A tuplizer defines the contract for things which know how to manage
@@ -56,24 +57,21 @@
* @author Steve Ebersole
*/
public interface Tuplizer {
-
/**
* Extract the current values contained on the given entity.
*
* @param entity The entity from which to extract values.
* @return The current property values.
- * @throws HibernateException
*/
- public Object[] getPropertyValues(Object entity) throws HibernateException;
+ public Object[] getPropertyValues(Object entity);
/**
* Inject the given values into the given entity.
*
* @param entity The entity.
* @param values The values to be injected.
- * @throws HibernateException
*/
- public void setPropertyValues(Object entity, Object[] values) throws HibernateException;
+ public void setPropertyValues(Object entity, Object[] values);
/**
* Extract the value of a particular property from the given entity.
@@ -81,17 +79,15 @@
* @param entity The entity from which to extract the property value.
* @param i The index of the property for which to extract the value.
* @return The current value of the given property on the given entity.
- * @throws HibernateException
*/
- public Object getPropertyValue(Object entity, int i) throws HibernateException;
+ public Object getPropertyValue(Object entity, int i);
/**
* Generate a new, empty entity.
*
* @return The new, empty entity instance.
- * @throws HibernateException
*/
- public Object instantiate() throws HibernateException;
+ public Object instantiate();
/**
* Is the given object considered an instance of the the entity (acconting
@@ -115,4 +111,11 @@
*/
public Class getMappedClass();
+ /**
+ * Retrieve the getter for the specified property.
+ *
+ * @param i The property index.
+ * @return The property getter.
+ */
+ public Getter getGetter(int i);
}
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/component/AbstractComponentTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/component/AbstractComponentTuplizer.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/component/AbstractComponentTuplizer.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -42,7 +42,6 @@
* @author Steve Ebersole
*/
public abstract class AbstractComponentTuplizer implements ComponentTuplizer {
-
protected final Getter[] getters;
protected final Setter[] setters;
protected final int propertySpan;
@@ -71,15 +70,6 @@
i++;
}
hasCustomAccessors = foundCustomAccessor;
-
- String[] getterNames = new String[propertySpan];
- String[] setterNames = new String[propertySpan];
- Class[] propTypes = new Class[propertySpan];
- for ( int j = 0; j < propertySpan; j++ ) {
- getterNames[j] = getters[j].getMethodName();
- setterNames[j] = setters[j].getMethodName();
- propTypes[j] = getters[j].getReturnType();
- }
instantiator = buildInstantiator( component );
}
@@ -128,4 +118,7 @@
throw new UnsupportedOperationException();
}
+ public Getter getGetter(int i) {
+ return getters[i];
+ }
}
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/component/PojoComponentTuplizer.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -51,7 +51,6 @@
* @author Steve Ebersole
*/
public class PojoComponentTuplizer extends AbstractComponentTuplizer {
-
private final Class componentClass;
private ReflectionOptimizer optimizer;
private final Getter parentGetter;
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -140,7 +140,9 @@
Property property = (Property) iter.next();
getters[i] = buildPropertyGetter(property, mappingInfo);
setters[i] = buildPropertySetter(property, mappingInfo);
- if ( !property.isBasicPropertyAccessor() ) foundCustomAccessor = true;
+ if ( !property.isBasicPropertyAccessor() ) {
+ foundCustomAccessor = true;
+ }
i++;
}
hasCustomAccessors = foundCustomAccessor;
@@ -423,4 +425,18 @@
return getClass().getName() + '(' + getEntityMetamodel().getName() + ')';
}
+ public Getter getIdentifierGetter() {
+ return idGetter;
+ }
+
+ public Getter getVersionGetter() {
+ if ( getEntityMetamodel().isVersioned() ) {
+ return getGetter( getEntityMetamodel().getVersionPropertyIndex() );
+ }
+ return null;
+ }
+
+ public Getter getGetter(int i) {
+ return getters[i];
+ }
}
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/entity/EntityTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/entity/EntityTuplizer.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/entity/EntityTuplizer.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -30,6 +30,7 @@
import org.hibernate.HibernateException;
import org.hibernate.EntityNameResolver;
import org.hibernate.EntityMode;
+import org.hibernate.property.Getter;
import org.hibernate.tuple.Tuplizer;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -238,4 +239,18 @@
* @throws HibernateException If we are unable to determine an entity-name within the inheritence hierarchy.
*/
public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory);
+
+ /**
+ * Retrieve the getter for the identifier property. May return null.
+ *
+ * @return The getter for the identifier property.
+ */
+ public Getter getIdentifierGetter();
+
+ /**
+ * Retrieve the getter for the version property. May return null.
+ *
+ * @return The getter for the version property.
+ */
+ public Getter getVersionGetter();
}
\ No newline at end of file
Modified: core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -64,7 +64,6 @@
* @author Gavin King
*/
public class PojoEntityTuplizer extends AbstractEntityTuplizer {
-
static final Logger log = LoggerFactory.getLogger( PojoEntityTuplizer.class );
private final Class mappedClass;
Modified: core/trunk/core/src/main/java/org/hibernate/type/ComponentType.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/type/ComponentType.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/core/src/main/java/org/hibernate/type/ComponentType.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -38,6 +38,7 @@
import org.hibernate.FetchMode;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
+import org.hibernate.PropertyNotFoundException;
import org.hibernate.engine.CascadeStyle;
import org.hibernate.engine.Mapping;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -88,6 +89,10 @@
this.tuplizerMapping = metamodel.getTuplizerMapping();
}
+ public EntityModeToTuplizerMapping getTuplizerMapping() {
+ return tuplizerMapping;
+ }
+
public int[] sqlTypes(Mapping mapping) throws MappingException {
//Not called at runtime so doesn't matter if its slow :)
int[] sqlTypes = new int[getColumnSpan( mapping )];
@@ -656,4 +661,15 @@
return false;
}
+ public int getPropertyIndex(String name) {
+ String[] names = getPropertyNames();
+ for ( int i = 0, max = names.length; i < max; i++ ) {
+ if ( names[i].equals( name ) ) {
+ return i;
+ }
+ }
+ throw new PropertyNotFoundException(
+ "Unable to locate property named " + name + " on " + getReturnedClass().getName()
+ );
+ }
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -35,6 +35,7 @@
import javax.persistence.spi.LoadState;
import org.hibernate.SessionFactory;
+import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.cfg.Configuration;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -71,7 +72,7 @@
final Iterator<PersistentClass> classes = cfg.getClassMappings();
//a safe guard till we are confident that metamodel is wll tested
if ( !"disabled".equalsIgnoreCase( cfg.getProperty( "hibernate.ejb.metamodel.generation" ) ) ) {
- this.metamodel = new MetamodelImpl( classes );
+ this.metamodel = MetamodelImpl.buildMetamodel( classes, ( SessionFactoryImplementor ) sessionFactory );
}
else {
this.metamodel = null;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AbstractIdentifiableType.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AbstractIdentifiableType.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AbstractIdentifiableType.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -87,16 +87,18 @@
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
- public <Y> SingularAttribute<? super X, Y> getId(Class<Y> type) {
+ public <Y> SingularAttribute<? super X, Y> getId(Class<Y> javaType) {
final SingularAttribute<? super X, Y> id_;
if ( id != null ) {
checkSimpleId();
id_ = ( SingularAttribute<? super X, Y> ) id;
+ if ( javaType != id.getJavaType() ) {
+ throw new IllegalArgumentException( "Id attribute was not of specified type : " + javaType.getName() );
+ }
}
else {
- id_ = requireSupertype().getId( type );
+ id_ = requireSupertype().getId( javaType );
}
- // TODO : check that type and id_.getJavaType() are related
return id_;
}
@@ -117,10 +119,12 @@
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
- public <Y> SingularAttribute<X, Y> getDeclaredId(Class<Y> yClass) {
+ public <Y> SingularAttribute<X, Y> getDeclaredId(Class<Y> javaType) {
checkDeclaredId();
checkSimpleId();
- // TODO : check that type and id.getJavaType() are related
+ if ( javaType != id.getJavaType() ) {
+ throw new IllegalArgumentException( "Id attribute was not of specified type : " + javaType.getName() );
+ }
return (SingularAttribute<X, Y>) id;
}
@@ -177,18 +181,20 @@
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
- public <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> type) {
+ public <Y> SingularAttribute<? super X, Y> getVersion(Class<Y> javaType) {
if ( ! hasVersionAttribute() ) {
return null;
}
final SingularAttribute<? super X, Y> version_;
if ( version != null ) {
version_ = ( SingularAttribute<? super X, Y> ) version;
+ if ( javaType != version.getJavaType() ) {
+ throw new IllegalArgumentException( "Version attribute was not of specified type : " + javaType.getName() );
+ }
}
else {
- version_ = requireSupertype().getVersion( type );
+ version_ = requireSupertype().getVersion( javaType );
}
- // TODO : check that type and version_.getJavaType() are related
return version_;
}
@@ -196,9 +202,11 @@
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
- public <Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> yClass) {
+ public <Y> SingularAttribute<X, Y> getDeclaredVersion(Class<Y> javaType) {
checkDeclaredVersion();
- // TODO : check that type and version_.getJavaType() are related
+ if ( javaType != version.getJavaType() ) {
+ throw new IllegalArgumentException( "Version attribute was not of specified type : " + javaType.getName() );
+ }
return ( SingularAttribute<X, Y> ) version;
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/AttributeFactory.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -23,18 +23,22 @@
*/
package org.hibernate.ejb.metamodel;
+import java.lang.reflect.Member;
import java.util.Iterator;
-import java.lang.reflect.Member;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.Type;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Value;
+import org.hibernate.EntityMode;
+import org.hibernate.type.EmbeddedComponentType;
+import org.hibernate.type.ComponentType;
+import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Component;
import org.hibernate.mapping.Map;
-import org.hibernate.mapping.Component;
import org.hibernate.mapping.OneToMany;
-import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Value;
+import org.hibernate.tuple.entity.EntityMetamodel;
/**
* TODO : javadoc
@@ -57,12 +61,12 @@
attribute = buildPluralAttribute( ownerType, property, attrContext );
}
else {
- final Type<Y> attrType = getType( attrContext.getElementTypeStatus(), attrContext.getElementValue() );
+ final Type<Y> attrType = getType( ownerType, attrContext.getElementTypeStatus(), attrContext.getElementValue() );
attribute = new SingularAttributeImpl<X,Y>(
property.getName(),
property.getType().getReturnedClass(),
ownerType,
- determineJavaMember( property ),
+ determineStandardJavaMember( ownerType, property ),
false,
false,
property.isOptional(),
@@ -76,19 +80,19 @@
@SuppressWarnings( "unchecked" )
private <X, Y, V, K> AttributeImplementor<X, Y> buildPluralAttribute(AbstractManagedType<X> ownerType, Property property, AttributeContext attrContext) {
AttributeImplementor<X, Y> attribute;
- final Type<V> attrType = getType( attrContext.getElementTypeStatus(), attrContext.getElementValue() );
+ final Type<V> attrType = getType( ownerType, attrContext.getElementTypeStatus(), attrContext.getElementValue() );
final Class<Y> collectionClass = (Class<Y>) attrContext.getCollectionClass();
if ( java.util.Map.class.isAssignableFrom( collectionClass ) ) {
- final Type<K> keyType = getType( attrContext.getKeyTypeStatus(), attrContext.getKeyValue() );
+ final Type<K> keyType = getType( ownerType, attrContext.getKeyTypeStatus(), attrContext.getKeyValue() );
attribute = PluralAttributeImpl.create( ownerType, attrType, collectionClass, keyType )
- .member( determineJavaMember( property ) )
+ .member( determineStandardJavaMember( ownerType, property ) )
.property( property )
.persistentAttributeType( attrContext.getElementAttributeType() )
.build();
}
else {
attribute = PluralAttributeImpl.create( ownerType, attrType, collectionClass, null )
- .member( determineJavaMember( property ) )
+ .member( determineStandardJavaMember( ownerType, property ) )
.property( property )
.persistentAttributeType( attrContext.getElementAttributeType() )
.build();
@@ -96,13 +100,13 @@
return attribute;
}
- private <X> Type<X> getType(AttributeContext.TypeStatus elementTypeStatus, Value value) {
+ private <X> Type<X> getType(AbstractManagedType owner, AttributeContext.TypeStatus elementTypeStatus, Value value) {
final org.hibernate.type.Type type = value.getType();
switch ( elementTypeStatus ) {
case BASIC:
return buildBasicType( type );
case EMBEDDABLE:
- return buildEmbeddableType( value, type );
+ return buildEmbeddableType( owner, value, type );
case ENTITY:
return buildEntityType( type );
default:
@@ -124,10 +128,10 @@
}
@SuppressWarnings( "unchecked" )
- private <X> Type<X> buildEmbeddableType(Value value, org.hibernate.type.Type type) {
+ private <X> Type<X> buildEmbeddableType(AbstractManagedType owner, Value value, org.hibernate.type.Type type) {
//build embedable type
final Class<X> clazz = type.getReturnedClass();
- final EmbeddableTypeImpl<X> embeddableType = new EmbeddableTypeImpl<X>( clazz );
+ final EmbeddableTypeImpl<X> embeddableType = new EmbeddableTypeImpl<X>( clazz, owner, (ComponentType) type );
context.registerEmbeddedableType( embeddableType );
final Component component = (Component) value;
final Iterator<Property> subProperties = component.getPropertyIterator();
@@ -142,38 +146,115 @@
@SuppressWarnings({ "unchecked" })
public <X, Y> SingularAttributeImpl<X, Y> buildIdAttribute(AbstractManagedType<X> ownerType, Property property) {
final AttributeContext attrContext = getAttributeContext( property );
- final Type<Y> attrType = getType( attrContext.getElementTypeStatus(), attrContext.getElementValue() );
+ final Type<Y> attrType = getType( ownerType, attrContext.getElementTypeStatus(), attrContext.getElementValue() );
final Class<Y> idJavaType = property.getType().getReturnedClass();
return new SingularAttributeImpl.Identifier(
property.getName(),
idJavaType,
ownerType,
- determineJavaMember( property ),
+ determineIdentifierJavaMember( ownerType, property ),
attrType,
attrContext.getElementAttributeType()
);
}
- @SuppressWarnings({ "UnusedDeclaration" })
- private Member determineJavaMember(Property property) {
- return null;
+ private Member determineIdentifierJavaMember(AbstractManagedType ownerType, Property property) {
+// see below
+// final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( property );
+ final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( ownerType );
+ if ( ! property.getName().equals( entityMetamodel.getIdentifierProperty().getName() ) ) {
+ // this *should* indicate processing part of an IdClass...
+ return determineVirtualIdentifierJavaMember( entityMetamodel, property );
+ }
+ return entityMetamodel.getTuplizer( EntityMode.POJO ).getIdentifierGetter().getMember();
}
+ private Member determineVirtualIdentifierJavaMember(EntityMetamodel entityMetamodel, Property property) {
+ if ( ! entityMetamodel.getIdentifierProperty().isVirtual() ) {
+ throw new IllegalArgumentException( "expecting IdClass mapping" );
+ }
+ org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
+ if ( ! EmbeddedComponentType.class.isInstance( type ) ) {
+ throw new IllegalArgumentException( "expecting IdClass mapping" );
+ }
+ final EmbeddedComponentType componentType = (EmbeddedComponentType) type;
+ return componentType.getTuplizerMapping()
+ .getTuplizer( EntityMode.POJO )
+ .getGetter( componentType.getPropertyIndex( property.getName() ) )
+ .getMember();
+ }
+
+// getting the owning PersistentClass from the Property is broken in certain cases with annotations...
+// private EntityMetamodel getDeclarerEntityMetamodel(Property property) {
+// return context.getSessionFactory()
+// .getEntityPersister( property.getPersistentClass().getEntityName() )
+// .getEntityMetamodel();
+// }
+// so we use the owner's java class to lookup the persister/entitymetamodel
+ private EntityMetamodel getDeclarerEntityMetamodel(AbstractManagedType ownerType) {
+ return context.getSessionFactory()
+ .getEntityPersister( ownerType.getJavaType().getName() )
+ .getEntityMetamodel();
+ }
+
+// getting the owning PersistentClass from the Property is broken in certain cases with annotations...
+// private Member determineStandardJavaMember(Property property) {
+// final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( property );
+//
+// final String propertyName = property.getName();
+// final int index = entityMetamodel.getPropertyIndex( propertyName );
+// return entityMetamodel.getTuplizer( EntityMode.POJO ).getGetter( index ).getMember();
+// }
+// so we use the owner's java class to lookup the persister/entitymetamodel
+ private Member determineStandardJavaMember(AbstractManagedType ownerType, Property property) {
+ if ( Type.PersistenceType.EMBEDDABLE == ownerType.getPersistenceType() ) {
+ EmbeddableTypeImpl embeddableType = ( EmbeddableTypeImpl ) ownerType;
+ return embeddableType.getHibernateType().getTuplizerMapping()
+ .getTuplizer( EntityMode.POJO )
+ .getGetter( embeddableType.getHibernateType().getPropertyIndex( property.getName() ) )
+ .getMember();
+ }
+ else if ( Type.PersistenceType.ENTITY == ownerType.getPersistenceType() ) {
+ final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( ownerType );
+ final String propertyName = property.getName();
+ final Integer index = entityMetamodel.getPropertyIndexOrNull( propertyName );
+ if ( index == null ) {
+ // just like in #determineIdentifierJavaMember , this *should* indicate we have an IdClass mapping
+ return determineVirtualIdentifierJavaMember( entityMetamodel, property );
+ }
+ else {
+ return entityMetamodel.getTuplizer( EntityMode.POJO ).getGetter( index ).getMember();
+ }
+ }
+ else {
+ throw new IllegalArgumentException( "Unexpected owner type : " + ownerType.getPersistenceType() );
+ }
+ }
+
@SuppressWarnings({ "unchecked" })
public <X, Y> SingularAttributeImpl<X, Y> buildVerisonAttribute(AbstractManagedType<X> ownerType, Property property) {
final AttributeContext attrContext = getAttributeContext( property );
final Class<Y> javaType = property.getType().getReturnedClass();
- final Type<Y> attrType = getType( attrContext.getElementTypeStatus(), attrContext.getElementValue() );
+ final Type<Y> attrType = getType( ownerType, attrContext.getElementTypeStatus(), attrContext.getElementValue() );
return new SingularAttributeImpl.Version(
property.getName(),
javaType,
ownerType,
- determineJavaMember( property ),
+ determineVersionJavaMember( ownerType, property ),
attrType,
attrContext.getElementAttributeType()
);
}
+ private Member determineVersionJavaMember(AbstractManagedType ownerType, Property property) {
+ final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( ownerType );
+ if ( ! property.getName().equals( entityMetamodel.getVersionProperty().getName() ) ) {
+ // this should never happen, but to be safe...
+ throw new IllegalArgumentException( "Given property did not match declared version property" );
+ }
+ return entityMetamodel.getTuplizer( EntityMode.POJO ).getIdentifierGetter().getMember();
+ }
+
private static class AttributeContext {
private final Value elementValue;
private final TypeStatus typeStatus;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/EmbeddableTypeImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/EmbeddableTypeImpl.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/EmbeddableTypeImpl.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -21,11 +21,10 @@
*/
package org.hibernate.ejb.metamodel;
-import java.util.Iterator;
import java.io.Serializable;
import javax.persistence.metamodel.EmbeddableType;
-import org.hibernate.mapping.Property;
+import org.hibernate.type.ComponentType;
/**
* @author Emmanuel Bernard
@@ -34,11 +33,24 @@
extends AbstractManagedType<X>
implements EmbeddableType<X>, Serializable {
- public EmbeddableTypeImpl(Class<X> javaType) {
+ private final AbstractManagedType parent;
+ private final ComponentType hibernateType;
+
+ public EmbeddableTypeImpl(Class<X> javaType, AbstractManagedType parent, ComponentType hibernateType) {
super( javaType, null );
+ this.parent = parent;
+ this.hibernateType = hibernateType;
}
public PersistenceType getPersistenceType() {
return PersistenceType.EMBEDDABLE;
}
+
+ public AbstractManagedType getParent() {
+ return parent;
+ }
+
+ public ComponentType getHibernateType() {
+ return hibernateType;
+ }
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -33,6 +33,7 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
+import org.hibernate.engine.SessionFactoryImplementor;
/**
* Defines a context for storing information during the building of the {@link MetamodelImpl}.
@@ -44,6 +45,7 @@
* @author Emmanuel Bernard
*/
class MetadataContext {
+ private final SessionFactoryImplementor sessionFactory;
private final AttributeFactory attributeFactory = new AttributeFactory( this );
private HashMap<Class<?>,EntityTypeImpl<?>> entityTypes
@@ -55,6 +57,14 @@
private HashMap<Class<?>, EmbeddableTypeImpl<?>> embeddables
= new HashMap<Class<?>, EmbeddableTypeImpl<?>>();
+ public MetadataContext(SessionFactoryImplementor sessionFactory) {
+ this.sessionFactory = sessionFactory;
+ }
+
+ /*package*/ SessionFactoryImplementor getSessionFactory() {
+ return sessionFactory;
+ }
+
/**
* Given a Hibernate {@link PersistentClass}, locate the corresponding JPA {@link org.hibernate.type.EntityType}
* implementation. May retur null if the given {@link PersistentClass} has not yet been processed.
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetamodelImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetamodelImpl.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetamodelImpl.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -32,6 +32,7 @@
import javax.persistence.metamodel.EmbeddableType;
import org.hibernate.mapping.PersistentClass;
+import org.hibernate.engine.SessionFactoryImplementor;
/**
* Hibernate implementation of the JPA {@link Metamodel} contract.
@@ -44,21 +45,25 @@
private final Map<Class<?>, EmbeddableTypeImpl<?>> embeddables;
/**
- * Instantiate the metamodel from the collection of Hibernate {@link PersistentClass} models.
+ * Build the metamodel using the information from the collection of Hibernate
+ * {@link PersistentClass} models as well as the Hibernate {@link SessionFactory}.
*
- * @param persistentClasses An iterator over the Hibernate {@link PersistentClass} models.
+ * @param persistentClasses Iterator over the Hibernate (config-time) metamodel
+ * @param sessionFactory The Hibernate session factry.
+ * @return The built metamodel
*/
- public MetamodelImpl(Iterator<PersistentClass> persistentClasses) {
- MetadataContext context = new MetadataContext();
+ public static MetamodelImpl buildMetamodel(
+ Iterator<PersistentClass> persistentClasses,
+ SessionFactoryImplementor sessionFactory) {
+ MetadataContext context = new MetadataContext( sessionFactory );
while ( persistentClasses.hasNext() ) {
locateOrBuildEntityType( persistentClasses.next(), context );
}
- this.entities = context.getEntityTypeMap();
context.wrapUp();
- this.embeddables = context.getEmbeddableTypeMap();
+ return new MetamodelImpl( context.getEntityTypeMap(), context.getEmbeddableTypeMap() );
}
- private EntityTypeImpl<?> locateOrBuildEntityType(PersistentClass persistentClass, MetadataContext context) {
+ private static EntityTypeImpl<?> locateOrBuildEntityType(PersistentClass persistentClass, MetadataContext context) {
EntityTypeImpl<?> entityType = context.locateEntityType( persistentClass );
if ( entityType == null ) {
entityType = buildEntityType( persistentClass, context );
@@ -67,7 +72,7 @@
}
@SuppressWarnings({ "unchecked" })
- private EntityTypeImpl<?> buildEntityType(PersistentClass persistentClass, MetadataContext context) {
+ private static EntityTypeImpl<?> buildEntityType(PersistentClass persistentClass, MetadataContext context) {
final PersistentClass superPersistentClass = persistentClass.getSuperclass();
final EntityTypeImpl superEntityType = superPersistentClass == null
? null
@@ -85,6 +90,19 @@
}
/**
+ * Instantiate the metamodel.
+ *
+ * @param entities The entity mappings.
+ * @param embeddables The embeddable (component) mappings.
+ */
+ private MetamodelImpl(
+ Map<Class<?>, EntityTypeImpl<?>> entities,
+ Map<Class<?>, EmbeddableTypeImpl<?>> embeddables) {
+ this.entities = entities;
+ this.embeddables = embeddables;
+ }
+
+ /**
* {@inheritDoc}
*/
@SuppressWarnings({ "unchecked" })
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java 2009-10-26 16:45:45 UTC (rev 17842)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/metadata/MetadataTest.java 2009-10-26 17:04:59 UTC (rev 17843)
@@ -37,6 +37,16 @@
final SingularAttribute<Fridge, Long> id = fridgeType.getDeclaredId( Long.class );
assertNotNull( id );
assertTrue( id.isId() );
+ try {
+ fridgeType.getDeclaredId( java.util.Date.class );
+ fail( "expecting failure" );
+ }
+ catch ( IllegalArgumentException ignore ) {
+ // expected result
+ }
+ final SingularAttribute<? super Fridge, Long> id2 = fridgeType.getId( Long.class );
+ assertNotNull( id2 );
+
assertEquals( Fridge.class.getName(), fridgeType.getName() );
assertEquals( Long.class, fridgeType.getIdType().getJavaType() );
assertTrue( fridgeType.hasSingleIdAttribute() );
14 years, 6 months
Hibernate SVN: r17842 - validator/trunk/hibernate-validator/src/main/docbook/en-US/modules.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-26 12:45:45 -0400 (Mon, 26 Oct 2009)
New Revision: 17842
Modified:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
Log:
HV-258
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-10-26 16:24:37 UTC (rev 17841)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-10-26 16:45:45 UTC (rev 17842)
@@ -172,8 +172,8 @@
<classname>ConstraintValidator</classname>. Class level constraints are
useful if it is necessary to inspect more than a single property of the
class to validate it or if a correlation between different state
- variables has to be evaluated. In <xref linkend="Car-example" /> we add
- the property <property>passengers</property> to the class
+ variables has to be evaluated. In <xref linkend="example-class-level" />
+ we add the property <property>passengers</property> to the class
<classname>Car</classname>. We also add the constraint
<classname>PassengerCount</classname> on the class level. We will later
see how we can actually create this custom constraint (see <xref
@@ -181,7 +181,7 @@
know that <classname>PassengerCount</classname> will ensure that there
cannot be more passengers in a car than there are seats.</para>
- <para><example xreflabel="Car-example">
+ <para><example id="example-class-level">
<title>Class level constraint</title>
<programlisting language="Java">package com.mycompany;
14 years, 6 months
Hibernate SVN: r17841 - in validator/trunk: hibernate-validator/src/main/docbook/en-US and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-26 12:24:37 -0400 (Mon, 26 Oct 2009)
New Revision: 17841
Modified:
validator/trunk/hibernate-validator-tck-runner/pom.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
validator/trunk/pom.xml
Log:
Updated version number in prep for the coming release
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-10-26 16:23:42 UTC (rev 17840)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-10-26 16:24:37 UTC (rev 17841)
@@ -25,7 +25,7 @@
-->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY versionNumber "4.0.0.GA">
+<!ENTITY versionNumber "4.0.1.GA">
<!ENTITY copyrightYear "2009">
<!ENTITY copyrightHolder "Red Hat Middleware, LLC. & Gunnar Morling">
]>
Modified: validator/trunk/hibernate-validator-tck-runner/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-10-26 16:23:42 UTC (rev 17840)
+++ validator/trunk/hibernate-validator-tck-runner/pom.xml 2009-10-26 16:24:37 UTC (rev 17841)
@@ -32,7 +32,7 @@
<dependency>
<groupId>org.hibernate.jsr303.tck</groupId>
<artifactId>jsr303-tck</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.1.GA-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.test-harness</groupId>
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2009-10-26 16:23:42 UTC (rev 17840)
+++ validator/trunk/pom.xml 2009-10-26 16:24:37 UTC (rev 17841)
@@ -3,7 +3,7 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-parent</artifactId>
<packaging>pom</packaging>
- <version>4.0.1-SNAPSHOT</version>
+ <version>4.0.1.GA-SNAPSHOT</version>
<name>Hibernate Validator Parent</name>
<url>http://validator.hibernate.org</url>
14 years, 6 months
Hibernate SVN: r17840 - beanvalidation/tck/trunk/src/main/docbook/en-US/harness.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-26 12:23:42 -0400 (Mon, 26 Oct 2009)
New Revision: 17840
Modified:
beanvalidation/tck/trunk/src/main/docbook/en-US/harness/executing.xml
Log:
Updated version number in prep for the coming release
Modified: beanvalidation/tck/trunk/src/main/docbook/en-US/harness/executing.xml
===================================================================
--- beanvalidation/tck/trunk/src/main/docbook/en-US/harness/executing.xml 2009-10-26 16:16:30 UTC (rev 17839)
+++ beanvalidation/tck/trunk/src/main/docbook/en-US/harness/executing.xml 2009-10-26 16:23:42 UTC (rev 17840)
@@ -60,7 +60,7 @@
<entry>hibernate-validator</entry>
- <entry>4.0.0.GA</entry>
+ <entry>4.0.1.GA</entry>
</row>
<row>
@@ -68,7 +68,7 @@
<entry>jsr303-tck</entry>
- <entry>1.0.0.GA</entry>
+ <entry>1.0.1.GA</entry>
</row>
<row>
14 years, 6 months
Hibernate SVN: r17839 - beanvalidation/tck/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-26 12:16:30 -0400 (Mon, 26 Oct 2009)
New Revision: 17839
Modified:
beanvalidation/tck/trunk/pom.xml
Log:
Updated version number in prep for the coming release
Modified: beanvalidation/tck/trunk/pom.xml
===================================================================
--- beanvalidation/tck/trunk/pom.xml 2009-10-26 16:11:42 UTC (rev 17838)
+++ beanvalidation/tck/trunk/pom.xml 2009-10-26 16:16:30 UTC (rev 17839)
@@ -4,7 +4,7 @@
<groupId>org.hibernate.jsr303.tck</groupId>
<artifactId>jsr303-tck</artifactId>
<packaging>jar</packaging>
- <version>1.0.1-SNAPSHOT</version>
+ <version>1.0.1.GA-SNAPSHOT</version>
<name>JSR-303 TCK</name>
<url>http://validator.hibernate.org</url>
14 years, 6 months
Hibernate SVN: r17838 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validator/engine and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-10-26 12:11:42 -0400 (Mon, 26 Oct 2009)
New Revision: 17838
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/A.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/B.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/ProxyTest.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/ReflectionHelper.java
Log:
HV-257
Changed the implementation of ReflectionHelper.setAccessibility() to take into accound the abstract keyword
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/ReflectionHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/ReflectionHelper.java 2009-10-26 05:26:51 UTC (rev 17837)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/ReflectionHelper.java 2009-10-26 16:11:42 UTC (rev 17838)
@@ -181,10 +181,14 @@
return value;
}
- //run client in privileged block
static void setAccessibility(Member member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- //Sun's ease of use, sigh...
+ // HV-257
+ // Also set accessibility in case of public abstract members. If you proxy an interface using java.lang.reflect.Proxy
+ // per default you will get a IllegalAccessException since you are not allowed to access public abstract methods.
+ // Seems odd. One could argue that the proxy 'is' the implementation for the interface method and hence they
+ // should be accessible. Maybe this is a JVM bug !?
+ if ( !Modifier.isPublic( member.getModifiers() )
+ || ( Modifier.isPublic( member.getModifiers() ) && Modifier.isAbstract( member.getModifiers() ) ) ) {
( ( AccessibleObject ) member ).setAccessible( true );
}
}
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/A.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/A.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/A.java 2009-10-26 16:11:42 UTC (rev 17838)
@@ -0,0 +1,29 @@
+// $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.validator.engine.proxy;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Size;
+
+interface A {
+ @Min(5)
+ public Integer getInteger();
+
+ @Size(min = 2)
+ public String getString();
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/A.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/B.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/B.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/B.java 2009-10-26 16:11:42 UTC (rev 17838)
@@ -0,0 +1,24 @@
+// $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.validator.engine.proxy;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Size;
+
+public interface B extends A {
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/B.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/ProxyTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/ProxyTest.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/ProxyTest.java 2009-10-26 16:11:42 UTC (rev 17838)
@@ -0,0 +1,83 @@
+// $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.validator.engine.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+import org.hibernate.validator.util.TestUtil;
+import static org.hibernate.validator.util.TestUtil.assertNumberOfViolations;
+
+/**
+ * See HV-257
+ *
+ * @author Hardy Ferentschik
+ */
+public class ProxyTest {
+ @Test
+ public void testValidateA() {
+ InvocationHandler handler = new CustomInvocationHandler( "some object" );
+
+ A a = ( A ) Proxy.newProxyInstance( getClass().getClassLoader(), new Class<?>[] { A.class }, handler );
+ assertEquals( Integer.valueOf( 0 ), a.getInteger() );
+
+ Validator validator = TestUtil.getValidator();
+ Set<ConstraintViolation<A>> violations = validator.validate( a );
+ assertNumberOfViolations( violations, 2 );
+ }
+
+ @Test
+ public void testValidateB() {
+ InvocationHandler handler = new CustomInvocationHandler( "some object" );
+
+ B b = ( B ) Proxy.newProxyInstance( getClass().getClassLoader(), new Class<?>[] { B.class }, handler );
+ assertEquals( Integer.valueOf( 0 ), b.getInteger() );
+
+ Validator validator = TestUtil.getValidator();
+ Set<ConstraintViolation<B>> violations = validator.validate( b );
+ assertNumberOfViolations( violations, 2 );
+ }
+
+ private class CustomInvocationHandler implements InvocationHandler {
+ private Object o;
+
+ public CustomInvocationHandler(Object o) {
+ this.o = o;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if ( method.getName().equals( "getInteger" ) ) {
+ method.setAccessible( true );
+ return 0;
+ }
+ if ( method.getName().equals( "getString" ) ) {
+ return "a";
+ }
+ return method.invoke( o, args );
+ }
+ }
+}
+
+
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/engine/proxy/ProxyTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
14 years, 6 months
Hibernate SVN: r17837 - core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-10-26 01:26:51 -0400 (Mon, 26 Oct 2009)
New Revision: 17837
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java
Log:
HHH-4202 - Implement JPA 2.0 metamodel APIs
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java 2009-10-26 05:23:40 UTC (rev 17836)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/metamodel/MetadataContext.java 2009-10-26 05:26:51 UTC (rev 17837)
@@ -156,9 +156,7 @@
Set<SingularAttribute<? super X, ?>> attributes = new HashSet<SingularAttribute<? super X, ?>>();
Iterator<Property> properties = persistentClass.getIdentifierMapper().getPropertyIterator();
while ( properties.hasNext() ) {
- attributes.add(
- (SingularAttribute<? super X, ?>) attributeFactory.buildAttribute( jpaEntityType, properties.next() )
- );
+ attributes.add( attributeFactory.buildIdAttribute( jpaEntityType, properties.next() ) );
}
return attributes;
}
14 years, 6 months