Hibernate SVN: r18403 - in core/trunk/annotations/src: test/java/org/hibernate/test/annotations/manytoonewithformula and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sharathjreddy
Date: 2010-01-04 15:12:33 -0500 (Mon, 04 Jan 2010)
New Revision: 18403
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Contract.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ContractId.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Manufacturer.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManufacturerId.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Model.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ModelId.java
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManyToOneWithFormulaTest.java
Log:
HHH-4653
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java 2010-01-04 19:10:05 UTC (rev 18402)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -570,17 +570,19 @@
*/
public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) {
- // columnDefinition can also be specified using @JoinColumn, hence we have to check
- // whether it is set or not
- if ( StringHelper.isEmpty( sqlType ) ) {
- sqlType = column.getSqlType();
- if ( getMappingColumn() != null ) getMappingColumn().setSqlType( sqlType );
+ if (getMappingColumn() != null) {
+ // columnDefinition can also be specified using @JoinColumn, hence we have to check
+ // whether it is set or not
+ if ( StringHelper.isEmpty( sqlType ) ) {
+ sqlType = column.getSqlType();
+ getMappingColumn().setSqlType( sqlType );
+ }
+
+ // these properties can only be applied on the referenced column - we can just take them over
+ getMappingColumn().setLength(column.getLength());
+ getMappingColumn().setPrecision(column.getPrecision());
+ getMappingColumn().setScale(column.getScale());
}
-
- // these properties can only be applied on the referenced column - we can just take them over
- getMappingColumn().setLength(column.getLength());
- getMappingColumn().setPrecision(column.getPrecision());
- getMappingColumn().setScale(column.getScale());
}
@Override
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Contract.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Contract.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Contract.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -0,0 +1,105 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, 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.test.annotations.manytoonewithformula;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.JoinColumnOrFormula;
+import org.hibernate.annotations.JoinColumnsOrFormulas;
+import org.hibernate.annotations.JoinFormula;
+
+@Entity
+@Table(name = "CONTRACT")
+public class Contract {
+ private String contractNumber;
+
+ // private Integer companyCode;
+
+ private ContractId id;
+
+ private Manufacturer manufacturer;
+
+ private Model model;
+
+ public Contract() {
+ }
+
+ @Id
+ public ContractId getId() {
+ return id;
+ }
+
+ public void setId(ContractId id) {
+ this.id = id;
+ }
+
+ @ManyToOne
+ @JoinColumnsOrFormulas( {
+ @JoinColumnOrFormula(column = @JoinColumn(name = "CDT_MDL_CODE", referencedColumnName = "MDL_CODE")),
+ @JoinColumnOrFormula(formula = @JoinFormula(value = "CDT_MFG_CODE", referencedColumnName = "MDL_MFG_CODE")),
+ @JoinColumnOrFormula(formula = @JoinFormula(value = "CDT_COMPANY_CODE", referencedColumnName = "MDL_COMPANY_CODE"))})
+ public Model getModel() {
+ return model;
+ }
+
+ public void setModel(Model model) {
+ this.model = model;
+ }
+
+ @Column(name = "CDT_CONTRACT_NBR")
+ public String getContractNumber() {
+ return contractNumber;
+ }
+
+ public void setContractNumber(String contractNumber) {
+ this.contractNumber = contractNumber;
+ }
+
+ @ManyToOne
+ @JoinColumnsOrFormulas( {
+ @JoinColumnOrFormula(column = @JoinColumn(name = "CDT_MFG_CODE", referencedColumnName = "MFG_CODE")),
+ @JoinColumnOrFormula(formula = @JoinFormula(value = "CDT_COMPANY_CODE", referencedColumnName = "MFG_COMPANY_CODE")) })
+ public Manufacturer getManufacturer() {
+ return manufacturer;
+ }
+
+ public void setManufacturer(Manufacturer manufacturer) {
+ this.manufacturer = manufacturer;
+ }
+
+ @Override
+ public String toString() {
+ return contractNumber;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ContractId.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ContractId.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ContractId.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -0,0 +1,124 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, 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.test.annotations.manytoonewithformula;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class ContractId implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Integer companyCode;
+
+ private Long contractNumber;
+
+ private Integer contractSequenceNumber;
+
+ public ContractId() {
+ }
+
+ public ContractId(Integer companyCode, Long contractNumber,
+ Integer contractSequenceNumber) {
+ this.companyCode = companyCode;
+ this.contractNumber = contractNumber;
+ this.contractSequenceNumber = contractSequenceNumber;
+ }
+
+ @Column(name = "CDT_COMPANY_CODE")
+ public Integer getCompanyCode() {
+ return companyCode;
+ }
+
+ public void setCompanyCode(Integer companyCode) {
+ this.companyCode = companyCode;
+ }
+
+ @Column(name="CDT_NBR")
+ public Long getContractNumber() {
+ return contractNumber;
+ }
+
+ public void setContractNumber(Long contractNumber) {
+ this.contractNumber = contractNumber;
+ }
+
+ @Column(name="CDT_SEQ_NBR")
+ public Integer getContractSequenceNumber() {
+ return contractSequenceNumber;
+ }
+
+ public void setContractSequenceNumber(Integer contractSequenceNumber) {
+ this.contractSequenceNumber = contractSequenceNumber;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((companyCode == null) ? 0 : companyCode.hashCode());
+ result = prime * result
+ + ((contractNumber == null) ? 0 : contractNumber.hashCode());
+ result = prime
+ * result
+ + ((contractSequenceNumber == null) ? 0
+ : contractSequenceNumber.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ContractId other = (ContractId) obj;
+ if (companyCode == null) {
+ if (other.companyCode != null)
+ return false;
+ } else if (!companyCode.equals(other.companyCode))
+ return false;
+ if (contractNumber == null) {
+ if (other.contractNumber != null)
+ return false;
+ } else if (!contractNumber.equals(other.contractNumber))
+ return false;
+ if (contractSequenceNumber == null) {
+ if (other.contractSequenceNumber != null)
+ return false;
+ } else if (!contractSequenceNumber.equals(other.contractSequenceNumber))
+ return false;
+ return true;
+ }
+
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Manufacturer.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Manufacturer.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Manufacturer.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -0,0 +1,75 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, 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.test.annotations.manytoonewithformula;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "MANUFACTURER")
+public class Manufacturer {
+
+ private ManufacturerId id;
+
+ private String name;
+
+ public Manufacturer(ManufacturerId id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public Manufacturer() {
+ }
+
+ @Column(name = "MFG_NAME")
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Id
+ public ManufacturerId getId() {
+ return id;
+ }
+
+ public void setId(ManufacturerId id) {
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
+
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManufacturerId.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManufacturerId.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManufacturerId.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -0,0 +1,71 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, 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.test.annotations.manytoonewithformula;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class ManufacturerId implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Integer companyCode;
+
+ private Integer manufacturerCode;
+
+ public ManufacturerId(Integer companyCode, Integer manufacturerCode) {
+ this.companyCode = companyCode;
+ this.manufacturerCode = manufacturerCode;
+ }
+
+ public ManufacturerId() {
+ }
+
+ @Column(name = "MFG_COMPANY_CODE")
+ public Integer getCompanyCode() {
+ return companyCode;
+ }
+
+ public void setCompanyCode(Integer companyCode) {
+ this.companyCode = companyCode;
+ }
+
+ @Column(name = "MFG_CODE")
+ public Integer getManufacturerCode() {
+ return manufacturerCode;
+ }
+
+ public void setManufacturerCode(Integer manufacturerCode) {
+ this.manufacturerCode = manufacturerCode;
+ }
+
+}
+
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManyToOneWithFormulaTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManyToOneWithFormulaTest.java 2010-01-04 19:10:05 UTC (rev 18402)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ManyToOneWithFormulaTest.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -109,6 +109,46 @@
s.close();
}
+ public void testReferencedColumnNameBelongsToEmbeddedIdOfReferencedEntity() throws Exception {
+
+ Session session = openSession();
+ Transaction tx = session.beginTransaction();
+
+ Integer companyCode = 10;
+ Integer mfgCode = 100;
+ String contractNumber = "NSAR97841";
+ ContractId contractId = new ContractId(companyCode, 12457l, 1);
+
+ Manufacturer manufacturer = new Manufacturer(new ManufacturerId(
+ companyCode, mfgCode), "FORD");
+
+ Model model = new Model(new ModelId(companyCode, mfgCode, "FOCUS"),
+ "FORD FOCUS");
+
+ session.persist(manufacturer);
+ session.persist(model);
+
+ Contract contract = new Contract();
+ contract.setId(contractId);
+ contract.setContractNumber(contractNumber);
+ contract.setManufacturer(manufacturer);
+ contract.setModel(model);
+
+ session.persist(contract);
+
+ session.flush();
+ session.clear();
+
+ contract = (Contract) session.load(Contract.class, contractId);
+ assertEquals("NSAR97841", contract.getContractNumber());
+ assertEquals("FORD", contract.getManufacturer().getName());
+ assertEquals("FORD FOCUS", contract.getModel().getName());
+
+ tx.commit();
+ session.close();
+ }
+
+
/**
* @see org.hibernate.test.annotations.TestCase#getMappings()
*/
@@ -119,7 +159,13 @@
Company.class,
Person.class,
Message.class,
- Language.class
+ Language.class,
+ Contract.class,
+ ContractId.class,
+ Model.class,
+ ModelId.class,
+ Manufacturer.class,
+ ManufacturerId.class
};
}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Model.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Model.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/Model.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -0,0 +1,97 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, 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.test.annotations.manytoonewithformula;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="MODEL")
+public class Model {
+
+ private ModelId id;
+
+ private String name;
+
+ public Model(ModelId id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Model other = (Model) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
+ public Model() {
+ }
+
+ @Id
+ public ModelId getId() {
+ return id;
+ }
+
+ public void setId(ModelId id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
+
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ModelId.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ModelId.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/manytoonewithformula/ModelId.java 2010-01-04 20:12:33 UTC (rev 18403)
@@ -0,0 +1,126 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates 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, 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.test.annotations.manytoonewithformula;
+
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class ModelId implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private Integer companyCode;
+
+ private Integer manufacturerCode;
+
+ private String modelCode;
+
+ public ModelId(Integer companyCode, Integer manufacturerCode,
+ String modelCode) {
+ this.companyCode = companyCode;
+ this.manufacturerCode = manufacturerCode;
+ this.modelCode = modelCode;
+ }
+
+ public ModelId() {
+ }
+
+ @Column(name = "MDL_COMPANY_CODE")
+ public Integer getCompanyCode() {
+ return companyCode;
+ }
+
+ public void setCompanyCode(Integer companyCode) {
+ this.companyCode = companyCode;
+ }
+
+ @Column(name = "MDL_MFG_CODE")
+ public Integer getManufacturerCode() {
+ return manufacturerCode;
+ }
+
+ public void setManufacturerCode(Integer manufacturerCode) {
+ this.manufacturerCode = manufacturerCode;
+ }
+
+ @Column(name = "MDL_CODE")
+ public String getModelCode() {
+ return modelCode;
+ }
+
+ public void setModelCode(String modelCode) {
+ this.modelCode = modelCode;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((companyCode == null) ? 0 : companyCode.hashCode());
+ result = prime
+ * result
+ + ((manufacturerCode == null) ? 0 : manufacturerCode.hashCode());
+ result = prime * result
+ + ((modelCode == null) ? 0 : modelCode.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ModelId other = (ModelId) obj;
+ if (companyCode == null) {
+ if (other.companyCode != null)
+ return false;
+ } else if (!companyCode.equals(other.companyCode))
+ return false;
+ if (manufacturerCode == null) {
+ if (other.manufacturerCode != null)
+ return false;
+ } else if (!manufacturerCode.equals(other.manufacturerCode))
+ return false;
+ if (modelCode == null) {
+ if (other.modelCode != null)
+ return false;
+ } else if (!modelCode.equals(other.modelCode))
+ return false;
+ return true;
+ }
+
+}
+
14 years, 11 months
Hibernate SVN: r18402 - annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-04 14:10:05 -0500 (Mon, 04 Jan 2010)
New Revision: 18402
Modified:
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/EntityTest.java
Log:
JBPAPP-3327 org.hibernate.test.annotations.EntityTest.testColumn() is incorrect
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/EntityTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/EntityTest.java 2010-01-04 19:03:05 UTC (rev 18401)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/EntityTest.java 2010-01-04 19:10:05 UTC (rev 18402)
@@ -76,7 +76,7 @@
s = openSession();
tx = s.beginTransaction();
firstOne = new Flight();
- firstOne.setId( new Long( 1 ) );
+ firstOne.setId( new Long( 2 ) );
firstOne.setName( null );
try {
@@ -94,9 +94,7 @@
//insert an object and check that name is not updatable
s = openSession();
tx = s.beginTransaction();
- firstOne = new Flight();
- firstOne.setId( new Long( 1 ) );
- firstOne.setName( "AF3202" );
+ firstOne = (Flight) s.get( Flight.class, new Long( 1 ) );
firstOne.setTriggeredData( "should not be insertable" );
tx.commit();
s.close();
14 years, 11 months
Hibernate SVN: r18401 - annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-04 14:03:05 -0500 (Mon, 04 Jan 2010)
New Revision: 18401
Modified:
annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/EntityTest.java
Log:
JBPAPP-3057 Core - DB2 - Assertion Failed in EntityTest.testColumn
Modified: annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/EntityTest.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/EntityTest.java 2010-01-04 19:00:01 UTC (rev 18400)
+++ annotations/branches/v3_3_1_GA_CP/src/test/org/hibernate/test/annotations/EntityTest.java 2010-01-04 19:03:05 UTC (rev 18401)
@@ -50,13 +50,26 @@
tx.commit();
s.close();
}
-
+
public void testColumn() throws Exception {
//put an object in DB
Session s = openSession();
Transaction tx = s.beginTransaction();
Flight firstOne = new Flight();
firstOne.setId( new Long( 1 ) );
+ firstOne.setName( "AF3202" );
+ firstOne.setDuration( new Long( 1000000 ) );
+ firstOne.setDurationInSec( 2000 );
+ s.save( firstOne );
+ s.flush();
+ tx.commit();
+ s.close();
+
+
+ s = openSession();
+ tx = s.beginTransaction();
+ firstOne = new Flight();
+ firstOne.setId( new Long( 2 ) );
firstOne.setName( null );
try {
@@ -71,12 +84,9 @@
s.close();
}
- //insert an object and check that name is not updatable
s = openSession();
tx = s.beginTransaction();
- firstOne = new Flight();
- firstOne.setId( new Long( 1 ) );
- firstOne.setName( "AF3202" );
+ firstOne = (Flight) s.get( Flight.class, new Long( 1 ) );
firstOne.setTriggeredData( "should not be insertable" );
tx.commit();
s.close();
14 years, 11 months
Hibernate SVN: r18400 - in core/trunk/entitymanager/src: main/java/org/hibernate/ejb/criteria/expression and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-01-04 14:00:01 -0500 (Mon, 04 Jan 2010)
New Revision: 18400
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractNode.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.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/MapKeyHelpers.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/OrderImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryOperatorExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AbsFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/BasicFunctionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CastFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentDateFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimeFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimestampFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LengthFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LowerFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SqrtFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/UpperFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractSimplePredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java
Log:
HHH-4663 - Make sure CriteriaQuery is serializable
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.CollectionJoin;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Fetch;
@@ -47,7 +48,7 @@
*/
public abstract class AbstractBasicPluralJoin<O,C,E>
extends JoinImpl<O,E>
- implements PluralJoin<O,C,E>, Fetch<O,E> {
+ implements PluralJoin<O,C,E>, Fetch<O,E>, Serializable {
public AbstractBasicPluralJoin(
CriteriaBuilderImpl criteriaBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractNode.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractNode.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractNode.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,13 +23,15 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
+
/**
* All nodes in a criteria query tree will generally need access to the {@link CriteriaBuilderImpl} from which they
* come. This base class provides convenient, consistent support for that.
*
* @author Steve Ebersole
*/
-public class AbstractNode {
+public class AbstractNode implements Serializable {
private final CriteriaBuilderImpl criteriaBuilder;
public AbstractNode(CriteriaBuilderImpl criteriaBuilder) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute;
@@ -36,7 +37,7 @@
*/
public class BasicCollectionJoinImpl<O,E>
extends AbstractBasicPluralJoin<O,java.util.Collection<E>,E>
- implements JoinImplementors.CollectionJoinImplementor<O,E> {
+ implements JoinImplementors.CollectionJoinImplementor<O,E>, Serializable {
public BasicCollectionJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
@@ -38,7 +39,7 @@
*/
public class BasicListJoinImpl<O,E>
extends AbstractBasicPluralJoin<O,java.util.List<E>,E>
- implements JoinImplementors.ListJoinImplementor<O,E> {
+ implements JoinImplementors.ListJoinImplementor<O,E>, Serializable {
public BasicListJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.criteria.Expression;
@@ -46,7 +47,7 @@
*/
public class BasicMapJoinImpl<O,K,V>
extends AbstractBasicPluralJoin<O,java.util.Map<K,V>,V>
- implements JoinImplementors.MapJoinImplementor<O,K,V> {
+ implements JoinImplementors.MapJoinImplementor<O,K,V>, Serializable {
public BasicMapJoinImpl(
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute;
@@ -36,7 +37,7 @@
*/
public class BasicSetJoinImpl<O,E>
extends AbstractBasicPluralJoin<O,java.util.Set<E>,E>
- implements JoinImplementors.SetJoinImplementor<O,E> {
+ implements JoinImplementors.SetJoinImplementor<O,E>, Serializable {
public BasicSetJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
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 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.CollectionAttribute;
@@ -38,7 +39,7 @@
*/
public class CollectionJoinImpl<O,E>
extends JoinImpl<O,E>
- implements JoinImplementors.CollectionJoinImplementor<O,E> {
+ implements JoinImplementors.CollectionJoinImplementor<O,E>, Serializable {
public CollectionJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
@@ -56,7 +57,7 @@
*
* @author Steve Ebersole
*/
-public class CriteriaQueryCompiler {
+public class CriteriaQueryCompiler implements Serializable {
private static final Logger log = LoggerFactory.getLogger( CriteriaQueryCompiler.class );
public static interface ImplicitParameterBinding {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -47,7 +48,7 @@
*
* @author Steve Ebersole
*/
-public class CriteriaQueryImpl<T> extends AbstractNode implements CriteriaQuery<T> {
+public class CriteriaQueryImpl<T> extends AbstractNode implements CriteriaQuery<T>, Serializable {
private final Class<T> returnType;
private final QueryStructure<T> queryStructure;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
@@ -49,7 +50,7 @@
*
* @author Steve Ebersole
*/
-public class CriteriaSubqueryImpl<T> extends ExpressionImpl<T> implements Subquery<T> {
+public class CriteriaSubqueryImpl<T> extends ExpressionImpl<T> implements Subquery<T>, Serializable {
private final AbstractQuery<?> parent;
private final QueryStructure<T> queryStructure;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Set;
import java.util.Collection;
import java.util.Map;
@@ -59,7 +60,9 @@
*
* @author Steve Ebersole
*/
-public abstract class FromImpl<Z,X> extends PathImpl<X> implements From<Z,X>, TableExpressionMapper {
+public abstract class FromImpl<Z,X>
+ extends PathImpl<X>
+ implements From<Z,X>, TableExpressionMapper, Serializable {
public static final JoinType DEFAULT_JOIN_TYPE = JoinType.INNER;
private final Expression<Class<? extends X>> typeExpression;
@@ -69,7 +72,7 @@
/**
* Helper contract used to define who/what keeps track of joins and fetches made from this <tt>FROM</tt>.
*/
- public static interface JoinScope<X> {
+ public static interface JoinScope<X> extends Serializable {
public void addJoin(Join<X, ?> join);
public void addFetch(Fetch<X,?> fetch);
public boolean isCorrelated();
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 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.From;
import javax.persistence.criteria.JoinType;
import javax.persistence.metamodel.Attribute;
@@ -36,7 +37,9 @@
*
* @author Steve Ebersole
*/
-public class JoinImpl<Z, X> extends FromImpl<Z, X> implements JoinImplementors.JoinImplementor<Z,X> {
+public class JoinImpl<Z, X>
+ extends FromImpl<Z, X>
+ implements JoinImplementors.JoinImplementor<Z,X>, Serializable {
// TODO : keep track or whether any non-identifier properties get dereferenced
// for join optimization like in HQL
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 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
@@ -38,7 +39,9 @@
*
* @author Steve Ebersole
*/
-public class ListJoinImpl<O,E> extends JoinImpl<O,E> implements JoinImplementors.ListJoinImplementor<O,E> {
+public class ListJoinImpl<O,E>
+ extends JoinImpl<O,E>
+ implements JoinImplementors.ListJoinImplementor<O,E>, Serializable {
public ListJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
Class<E> javaType,
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 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.criteria.Expression;
@@ -43,7 +44,7 @@
*/
public class MapJoinImpl<O,K,V>
extends JoinImpl<O,V>
- implements JoinImplementors.MapJoinImplementor<O,K,V> {
+ implements JoinImplementors.MapJoinImplementor<O,K,V>, Serializable {
public MapJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.lang.reflect.Member;
import java.util.Map;
import java.util.Map.Entry;
@@ -60,8 +61,15 @@
* @param <K> The type of the map key
* @param <V> The type of the map value
*/
- public static class MapKeyJoin<K,V> extends JoinImpl<Map<K, V>, K> implements Join<Map<K, V>, K> {
- public MapKeyJoin(CriteriaBuilderImpl criteriaBuilder, MapPath<K,V> source, MapKeyAttribute<K> attribute, JoinType jt) {
+ public static class MapKeyJoin<K,V>
+ extends JoinImpl<Map<K, V>, K>
+ implements Join<Map<K, V>, K>, Serializable {
+
+ public MapKeyJoin(
+ CriteriaBuilderImpl criteriaBuilder,
+ MapPath<K,V> source,
+ MapKeyAttribute<K> attribute,
+ JoinType jt) {
super(
criteriaBuilder,
attribute.getJavaType(),
@@ -90,7 +98,7 @@
*
* @param <K> The type of the map key.
*/
- public static class MapKeyPath<K> extends PathImpl<K> implements Path<K> {
+ public static class MapKeyPath<K> extends PathImpl<K> implements Path<K>, Serializable {
public MapKeyPath(
CriteriaBuilderImpl criteriaBuilder,
MapPath<K,?> source,
@@ -106,7 +114,7 @@
* @param <K> The map key type
* @param <V> The map value type
*/
- public static class MapPath<K,V> extends PathImpl<Map<K, V>> implements Path<Map<K, V>> {
+ public static class MapPath<K,V> extends PathImpl<Map<K, V>> implements Path<Map<K, V>>, Serializable {
private final MapJoin<?,K,V> mapJoin;
public MapPath(
@@ -138,7 +146,7 @@
*
* @param <K> The type of the map key
*/
- public static class MapKeyAttribute<K> implements SingularAttribute<Map<K,?>,K> {
+ public static class MapKeyAttribute<K> implements SingularAttribute<Map<K,?>,K>, Serializable {
private final MapAttribute<?,K,?> attribute;
private final CollectionPersister mapPersister;
private final Type mapKeyType;
@@ -259,7 +267,7 @@
public static class MapEntryExpression<K,V>
extends ExpressionImpl<Map.Entry<K,V>>
- implements Expression<Map.Entry<K,V>> {
+ implements Expression<Map.Entry<K,V>>, Serializable {
private final PathImpl origin;
private final MapAttribute<?, K, V> attribute;
@@ -282,7 +290,7 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- // i dont think this is vqalid outside of select clause...
+ // i don't think this is valid outside of select clause...
throw new IllegalStateException( "illegal reference to map entry outside of select clause." );
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/OrderImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/OrderImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/OrderImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,15 +23,16 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Expression;
/**
- * TODO : javadoc
+ * Represents an <tt>ORDER BY</tt> fragment.
*
* @author Steve Ebersole
*/
-public class OrderImpl implements Order {
+public class OrderImpl implements Order, Serializable {
private final Expression<?> expression;
private boolean ascending;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import javax.persistence.criteria.Expression;
@@ -40,7 +41,7 @@
*
* @author Steve Ebersole
*/
-public class PathImpl<X> extends ExpressionImpl<X> implements Path<X> {
+public class PathImpl<X> extends ExpressionImpl<X> implements Path<X>, Serializable {
private final PathImpl<?> origin;
private final Attribute<?,?> attribute;
private Object model;
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 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
@@ -54,7 +55,7 @@
*
* @author Steve Ebersole
*/
-public class QueryStructure<T> {
+public class QueryStructure<T> implements Serializable {
private final AbstractQuery<T> owner;
private final CriteriaBuilderImpl criteriaBuilder;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.Attribute;
@@ -33,7 +34,7 @@
*
* @author Steve Ebersole
*/
-public class RootImpl<X> extends FromImpl<X,X> implements Root<X> {
+public class RootImpl<X> extends FromImpl<X,X> implements Root<X>, Serializable {
private RootImpl<X> correlationParent;
public RootImpl(
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 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.From;
import javax.persistence.metamodel.SetAttribute;
@@ -38,7 +39,7 @@
*/
public class SetJoinImpl<O,E>
extends JoinImpl<O,E>
- implements JoinImplementors.SetJoinImplementor<O,E> {
+ implements JoinImplementors.SetJoinImplementor<O,E>, Serializable {
public SetJoinImpl(
CriteriaBuilderImpl criteriaBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -40,7 +41,7 @@
public String render(T value);
}
- public static abstract class BaseValueHandler<T> implements ValueHandler<T> {
+ public static abstract class BaseValueHandler<T> implements ValueHandler<T>, Serializable {
public String render(T value) {
return value.toString();
}
@@ -73,7 +74,7 @@
|| Double.TYPE.isInstance( value );
}
- public static class ByteValueHandler extends BaseValueHandler<Byte> {
+ public static class ByteValueHandler extends BaseValueHandler<Byte> implements Serializable {
public static final ByteValueHandler INSTANCE = new ByteValueHandler();
@SuppressWarnings({ "UnnecessaryBoxing" })
public Byte convert(Object value) {
@@ -90,7 +91,7 @@
}
}
- public static class ShortValueHandler extends BaseValueHandler<Short> {
+ public static class ShortValueHandler extends BaseValueHandler<Short> implements Serializable {
public static final ShortValueHandler INSTANCE = new ShortValueHandler();
@SuppressWarnings({ "UnnecessaryBoxing" })
public Short convert(Object value) {
@@ -107,7 +108,7 @@
}
}
- public static class IntegerValueHandler extends BaseValueHandler<Integer> {
+ public static class IntegerValueHandler extends BaseValueHandler<Integer> implements Serializable {
public static final IntegerValueHandler INSTANCE = new IntegerValueHandler();
@SuppressWarnings({ "UnnecessaryBoxing" })
public Integer convert(Object value) {
@@ -124,7 +125,7 @@
}
}
- public static class LongValueHandler extends BaseValueHandler<Long> {
+ public static class LongValueHandler extends BaseValueHandler<Long> implements Serializable {
public static final LongValueHandler INSTANCE = new LongValueHandler();
@SuppressWarnings({ "UnnecessaryBoxing" })
public Long convert(Object value) {
@@ -146,7 +147,7 @@
}
}
- public static class FloatValueHandler extends BaseValueHandler<Float> {
+ public static class FloatValueHandler extends BaseValueHandler<Float> implements Serializable {
public static final FloatValueHandler INSTANCE = new FloatValueHandler();
@SuppressWarnings({ "UnnecessaryBoxing" })
public Float convert(Object value) {
@@ -168,7 +169,7 @@
}
}
- public static class DoubleValueHandler extends BaseValueHandler<Double> {
+ public static class DoubleValueHandler extends BaseValueHandler<Double> implements Serializable {
public static final DoubleValueHandler INSTANCE = new DoubleValueHandler();
@SuppressWarnings({ "UnnecessaryBoxing" })
public Double convert(Object value) {
@@ -190,7 +191,7 @@
}
}
- public static class BigIntegerValueHandler extends BaseValueHandler<BigInteger> {
+ public static class BigIntegerValueHandler extends BaseValueHandler<BigInteger> implements Serializable {
public static final BigIntegerValueHandler INSTANCE = new BigIntegerValueHandler();
public BigInteger convert(Object value) {
if ( value == null ) {
@@ -206,7 +207,7 @@
}
}
- public static class BigDecimalValueHandler extends BaseValueHandler<BigDecimal> {
+ public static class BigDecimalValueHandler extends BaseValueHandler<BigDecimal> implements Serializable {
public static final BigDecimalValueHandler INSTANCE = new BigDecimalValueHandler();
public BigDecimal convert(Object value) {
if ( value == null ) {
@@ -225,7 +226,7 @@
}
}
- public static class StringValueHandler extends BaseValueHandler<String> {
+ public static class StringValueHandler extends BaseValueHandler<String> implements Serializable {
public static final StringValueHandler INSTANCE = new StringValueHandler();
public String convert(Object value) {
return value == null ? null : value.toString();
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,8 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
+
import org.hibernate.ejb.criteria.AbstractNode;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.TupleElementImplementor;
@@ -35,7 +37,7 @@
*/
public abstract class AbstractTupleElement<X>
extends AbstractNode
- implements TupleElementImplementor<X> {
+ implements TupleElementImplementor<X>, Serializable {
private final Class originalJavaType;
private Class<X> javaType;
private String alias;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -37,7 +38,7 @@
*/
public class BinaryArithmeticOperation<N extends Number>
extends ExpressionImpl<N>
- implements BinaryOperatorExpression<N> {
+ implements BinaryOperatorExpression<N>, Serializable {
public static enum Operation {
ADD {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CoalesceExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.criteria.Expression;
@@ -37,7 +38,7 @@
*
* @author Steve Ebersole
*/
-public class CoalesceExpression<T> extends ExpressionImpl<T> implements Coalesce<T> {
+public class CoalesceExpression<T> extends ExpressionImpl<T> implements Coalesce<T>, Serializable {
private final List<Expression<? extends T>> expressions;
private Class<T> javaType;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.metamodel.PluralAttribute;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -36,7 +37,7 @@
*
* @author Steve Ebersole
*/
-public class CollectionExpression<C> extends ExpressionImpl<C> {
+public class CollectionExpression<C> extends ExpressionImpl<C> implements Serializable {
private final PathImpl origin;
private final CollectionPersister persister;
private final PluralAttribute<?, C, ?> attribute;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Tuple;
@@ -42,7 +43,9 @@
*
* @author Steve Ebersole
*/
-public class CompoundSelectionImpl<X> extends SelectionImpl<X> implements CompoundSelection<X>, Renderable {
+public class CompoundSelectionImpl<X>
+ extends SelectionImpl<X>
+ implements CompoundSelection<X>, Renderable, Serializable {
private final boolean isConstructor;
private List<Selection<?>> selectionItems;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ConcatExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -34,7 +35,7 @@
*
* @author Steve Ebersole
*/
-public class ConcatExpression extends ExpressionImpl<String> {
+public class ConcatExpression extends ExpressionImpl<String> implements Serializable {
private Expression<String> string1;
private Expression<String> string2;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,8 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
+
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
@@ -32,7 +34,7 @@
*
* @author Steve Ebersole
*/
-public class EntityTypeExpression<T> extends ExpressionImpl<T> {
+public class EntityTypeExpression<T> extends ExpressionImpl<T> implements Serializable {
public EntityTypeExpression(CriteriaBuilderImpl criteriaBuilder, Class<T> javaType) {
super( criteriaBuilder, javaType );
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
@@ -40,7 +41,7 @@
*/
public abstract class ExpressionImpl<T>
extends SelectionImpl<T>
- implements ExpressionImplementor<T> {
+ implements ExpressionImplementor<T>, Serializable {
public ExpressionImpl(CriteriaBuilderImpl criteriaBuilder, Class<T> javaType) {
super( criteriaBuilder, javaType );
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -34,7 +35,7 @@
*
* @author Steve Ebersole
*/
-public class ListIndexExpression extends ExpressionImpl<Integer> {
+public class ListIndexExpression extends ExpressionImpl<Integer> implements Serializable {
private final PathImpl origin;
private final ListAttribute<?,?> listAttribute;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.TypedQuery;
import org.hibernate.ejb.criteria.ValueHandlerFactory;
@@ -35,7 +36,7 @@
*
* @author Steve Ebersole
*/
-public class LiteralExpression<T> extends ExpressionImpl<T> {
+public class LiteralExpression<T> extends ExpressionImpl<T> implements Serializable {
private Object literal;
@SuppressWarnings({ "unchecked" })
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/NullifExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -34,7 +35,7 @@
*
* @author Steve Ebersole
*/
-public class NullifExpression<T> extends ExpressionImpl<T> {
+public class NullifExpression<T> extends ExpressionImpl<T> implements Serializable {
private final Expression<? extends T> primaryExpression;
private final Expression<?> secondaryExpression;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.ParameterExpression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -35,7 +36,9 @@
*
* @author Steve Ebersole
*/
-public class ParameterExpressionImpl<T> extends ExpressionImpl<T> implements ParameterExpression<T> {
+public class ParameterExpressionImpl<T>
+ extends ExpressionImpl<T>
+ implements ParameterExpression<T>, Serializable {
private final String name;
private final Integer position;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SearchedCaseExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.criteria.Expression;
@@ -44,7 +45,9 @@
*
* @author Steve Ebersole
*/
-public class SearchedCaseExpression<R> extends ExpressionImpl<R> implements Case<R> {
+public class SearchedCaseExpression<R>
+ extends ExpressionImpl<R>
+ implements Case<R>, Serializable {
private Class<R> javaType; // overrides the javaType kept on tuple-impl so that we can adjust it
private List<WhenClause> whenClauses = new ArrayList<WhenClause>();
private Expression<? extends R> otherwiseResult;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import javax.persistence.criteria.Selection;
@@ -40,7 +41,7 @@
*/
public abstract class SelectionImpl<X>
extends AbstractTupleElement<X>
- implements SelectionImplementor<X>, ParameterContainer {
+ implements SelectionImplementor<X>, ParameterContainer, Serializable {
public SelectionImpl(CriteriaBuilderImpl criteriaBuilder, Class<X> javaType) {
super( criteriaBuilder, javaType );
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SimpleCaseExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.criteria.Expression;
@@ -43,7 +44,9 @@
*
* @author Steve Ebersole
*/
-public class SimpleCaseExpression<C,R> extends ExpressionImpl<R> implements SimpleCase<C,R> {
+public class SimpleCaseExpression<C,R>
+ extends ExpressionImpl<R>
+ implements SimpleCase<C,R>, Serializable {
private Class<R> javaType;
private final Expression<? extends C> expression;
private List<WhenClause> whenClauses = new ArrayList<WhenClause>();
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import java.util.Collection;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -35,7 +36,8 @@
* @author Steve Ebersole
*/
public class SizeOfCollectionExpression<C extends Collection>
- extends ExpressionImpl<Integer> {
+ extends ExpressionImpl<Integer>
+ implements Serializable {
private final CollectionExpression<C> collectionExpression;
public SizeOfCollectionExpression(
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SubqueryComparisonModifierExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.Subquery;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -35,7 +36,9 @@
*
* @author Steve Ebersole
*/
-public class SubqueryComparisonModifierExpression<Y> extends ExpressionImpl<Y> {
+public class SubqueryComparisonModifierExpression<Y>
+ extends ExpressionImpl<Y>
+ implements Serializable {
public static enum Modifier {
ALL {
String rendered() {
@@ -77,7 +80,7 @@
}
public void registerParameters(ParameterRegistry registry) {
- // nothign to do (the subquery should be handled directly, and the modified itself is not parameterized)
+ // nothing to do (the subquery should be handled directly, and the modified itself is not parameterized)
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryArithmeticOperation.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -36,7 +37,7 @@
*/
public class UnaryArithmeticOperation<T>
extends ExpressionImpl<T>
- implements UnaryOperatorExpression<T> {
+ implements UnaryOperatorExpression<T>, Serializable {
public static enum Operation {
UNARY_PLUS, UNARY_MINUS
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryOperatorExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryOperatorExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/UnaryOperatorExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
/**
@@ -30,7 +31,7 @@
*
* @author Steve Ebersole
*/
-public interface UnaryOperatorExpression<T> extends Expression<T> {
+public interface UnaryOperatorExpression<T> extends Expression<T>, Serializable {
/**
* Get the operand.
*
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AbsFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AbsFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AbsFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -32,8 +33,8 @@
* @author Steve Ebersole
*/
public class AbsFunction<N extends Number>
- extends ParameterizedFunctionExpression<N> {
-
+ extends ParameterizedFunctionExpression<N>
+ implements Serializable {
public static final String NAME = "abs";
public AbsFunction(CriteriaBuilderImpl criteriaBuilder, Expression expression) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
@@ -33,7 +34,10 @@
*
* @author Steve Ebersole
*/
-public class AggregationFunction<T> extends ParameterizedFunctionExpression<T> {
+public class AggregationFunction<T>
+ extends ParameterizedFunctionExpression<T>
+ implements Serializable {
+
/**
* Constructs an aggregation function with a single literal argument.
*
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/BasicFunctionExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/BasicFunctionExpression.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/BasicFunctionExpression.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,8 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
+
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -30,13 +32,13 @@
import org.hibernate.ejb.criteria.expression.ExpressionImpl;
/**
- * Models the basic conept of a SQL function.
+ * Models the basic concept of a SQL function.
*
* @author Steve Ebersole
*/
public class BasicFunctionExpression<X>
extends ExpressionImpl<X>
- implements FunctionExpression<X> {
+ implements FunctionExpression<X>, Serializable {
private final String functionName;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CastFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CastFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CastFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,8 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
+
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
@@ -36,7 +38,9 @@
*
* @author Steve Ebersole
*/
-public class CastFunction<T,Y> extends BasicFunctionExpression<T> implements FunctionExpression<T> {
+public class CastFunction<T,Y>
+ extends BasicFunctionExpression<T>
+ implements FunctionExpression<T>, Serializable {
public static final String CAST_NAME = "cast";
private final ExpressionImpl<Y> castSource;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentDateFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentDateFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentDateFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,9 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
+import java.sql.Date;
+
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
/**
@@ -30,10 +33,12 @@
*
* @author Steve Ebersole
*/
-public class CurrentDateFunction extends BasicFunctionExpression<java.sql.Date> {
+public class CurrentDateFunction
+ extends BasicFunctionExpression<Date>
+ implements Serializable {
public static final String NAME = "current_date";
public CurrentDateFunction(CriteriaBuilderImpl criteriaBuilder) {
- super( criteriaBuilder, java.sql.Date.class, NAME );
+ super( criteriaBuilder, Date.class, NAME );
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimeFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimeFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimeFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,9 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
+import java.sql.Time;
+
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
/**
@@ -30,10 +33,12 @@
*
* @author Steve Ebersole
*/
-public class CurrentTimeFunction extends BasicFunctionExpression<java.sql.Time> {
+public class CurrentTimeFunction
+ extends BasicFunctionExpression<Time>
+ implements Serializable {
public static final String NAME = "current_time";
public CurrentTimeFunction(CriteriaBuilderImpl criteriaBuilder) {
- super( criteriaBuilder, java.sql.Time.class, NAME );
+ super( criteriaBuilder, Time.class, NAME );
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimestampFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimestampFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/CurrentTimestampFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import java.sql.Timestamp;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,7 +32,9 @@
*
* @author Steve Ebersole
*/
-public class CurrentTimestampFunction extends BasicFunctionExpression<Timestamp> {
+public class CurrentTimestampFunction
+ extends BasicFunctionExpression<Timestamp>
+ implements Serializable {
public static final String NAME = "current_timestamp";
public CurrentTimestampFunction(CriteriaBuilderImpl criteriaBuilder) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LengthFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LengthFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LengthFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,7 +32,9 @@
*
* @author Steve Ebersole
*/
-public class LengthFunction extends ParameterizedFunctionExpression<Integer> {
+public class LengthFunction
+ extends ParameterizedFunctionExpression<Integer>
+ implements Serializable {
public static final String NAME = "length";
public LengthFunction(CriteriaBuilderImpl criteriaBuilder, Expression<String> value) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LocateFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -36,7 +37,9 @@
*
* @author Steve Ebersole
*/
-public class LocateFunction extends BasicFunctionExpression<Integer> {
+public class LocateFunction
+ extends BasicFunctionExpression<Integer>
+ implements Serializable {
public static final String NAME = "locate";
private final Expression<String> pattern;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LowerFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LowerFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/LowerFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,7 +32,9 @@
*
* @author Steve Ebersole
*/
-public class LowerFunction extends ParameterizedFunctionExpression<String> {
+public class LowerFunction
+ extends ParameterizedFunctionExpression<String>
+ implements Serializable {
public static final String NAME = "lower";
public LowerFunction(CriteriaBuilderImpl criteriaBuilder, Expression<String> string) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SqrtFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SqrtFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SqrtFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,7 +32,9 @@
*
* @author Steve Ebersole
*/
-public class SqrtFunction extends ParameterizedFunctionExpression<Double> {
+public class SqrtFunction
+ extends ParameterizedFunctionExpression<Double>
+ implements Serializable {
public static final String NAME = "sqrt";
public SqrtFunction(CriteriaBuilderImpl criteriaBuilder, Expression<? extends Number> expression) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SubstringFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -36,7 +37,9 @@
*
* @author Steve Ebersole
*/
-public class SubstringFunction extends BasicFunctionExpression<String> {
+public class SubstringFunction
+ extends BasicFunctionExpression<String>
+ implements Serializable {
public static final String NAME = "substring";
private final Expression<String> value;
@@ -54,6 +57,7 @@
this.length = length;
}
+ @SuppressWarnings({ "RedundantCast" })
public SubstringFunction(
CriteriaBuilderImpl criteriaBuilder,
Expression<String> value,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/TrimFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.CriteriaBuilder.Trimspec;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -36,7 +37,9 @@
*
* @author Steve Ebersole
*/
-public class TrimFunction extends BasicFunctionExpression<String> {
+public class TrimFunction
+ extends BasicFunctionExpression<String>
+ implements Serializable {
public static final String NAME = "trim";
public static final Trimspec DEFAULT_TRIMSPEC = Trimspec.BOTH;
public static final char DEFAULT_TRIM_CHAR = ' ';
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/UpperFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/UpperFunction.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/UpperFunction.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.expression.function;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,7 +32,9 @@
*
* @author Steve Ebersole
*/
-public class UpperFunction extends ParameterizedFunctionExpression<String> {
+public class UpperFunction
+ extends ParameterizedFunctionExpression<String>
+ implements Serializable {
public static final String NAME = "upper";
public UpperFunction(CriteriaBuilderImpl criteriaBuilder, Expression<String> string) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import java.util.List;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Selection;
@@ -36,7 +37,9 @@
*
* @author Steve Ebersole
*/
-public abstract class AbstractPredicateImpl extends ExpressionImpl<Boolean> implements Predicate {
+public abstract class AbstractPredicateImpl
+ extends ExpressionImpl<Boolean>
+ implements Predicate, Serializable {
private boolean negated;
protected AbstractPredicateImpl(CriteriaBuilderImpl criteriaBuilder) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractSimplePredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractSimplePredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractSimplePredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import java.util.List;
import java.util.Collections;
import javax.persistence.criteria.Expression;
@@ -34,7 +35,9 @@
*
* @author Steve Ebersole
*/
-public abstract class AbstractSimplePredicate extends AbstractPredicateImpl {
+public abstract class AbstractSimplePredicate
+ extends AbstractPredicateImpl
+ implements Serializable {
private static final List<Expression<Boolean>> NO_EXPRESSIONS = Collections.emptyList();
public AbstractSimplePredicate(CriteriaBuilderImpl criteriaBuilder) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -35,7 +36,9 @@
*
* @author Steve Ebersole
*/
-public class BetweenPredicate<Y> extends AbstractSimplePredicate {
+public class BetweenPredicate<Y>
+ extends AbstractSimplePredicate
+ implements Serializable {
private final Expression<? extends Y> expression;
private final Expression<? extends Y> lowerBound;
private final Expression<? extends Y> upperBound;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,11 +32,18 @@
import org.hibernate.ejb.criteria.Renderable;
/**
- * TODO : javadoc
+ * Predicate to assert the explicit value of a boolean expression:<ul>
+ * <li>x = true</li>
+ * <li>x = false</li>
+ * <li>x <> true</li>
+ * <li>x <> false</li>
+ * </ul>
*
* @author Steve Ebersole
*/
-public class BooleanAssertionPredicate extends AbstractSimplePredicate {
+public class BooleanAssertionPredicate
+ extends AbstractSimplePredicate
+ implements Serializable {
private final Expression<Boolean> expression;
private final Boolean assertedValue;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanExpressionPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate;
@@ -36,7 +37,9 @@
*
* @author Steve Ebersole
*/
-public class BooleanExpressionPredicate extends AbstractSimplePredicate {
+public class BooleanExpressionPredicate
+ extends AbstractSimplePredicate
+ implements Serializable {
private final Expression<Boolean> expression;
public BooleanExpressionPredicate(CriteriaBuilderImpl criteriaBuilder, Expression<Boolean> expression) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ValueHandlerFactory;
@@ -38,7 +39,9 @@
*
* @author Steve Ebersole
*/
-public class ComparisonPredicate extends AbstractSimplePredicate implements BinaryOperatorExpression<Boolean> {
+public class ComparisonPredicate
+ extends AbstractSimplePredicate
+ implements BinaryOperatorExpression<Boolean>, Serializable {
private final ComparisonOperator comparisonOperator;
private final Expression<?> leftHandSide;
private final Expression<?> rightHandSide;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,7 +41,9 @@
*
* @author Steve Ebersole
*/
-public class CompoundPredicate extends AbstractPredicateImpl {
+public class CompoundPredicate
+ extends AbstractPredicateImpl
+ implements Serializable {
private final BooleanOperator operator;
private final List<Expression<Boolean>> expressions = new ArrayList<Expression<Boolean>>();
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExistsPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Subquery;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -34,7 +35,9 @@
*
* @author Steve Ebersole
*/
-public class ExistsPredicate extends AbstractSimplePredicate {
+public class ExistsPredicate
+ extends AbstractSimplePredicate
+ implements Serializable {
private final Subquery<?> subquery;
public ExistsPredicate(CriteriaBuilderImpl criteriaBuilder, Subquery<?> subquery) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ExplicitTruthValueCheck.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -40,7 +41,9 @@
*
* @author Steve Ebersole
*/
-public class ExplicitTruthValueCheck extends AbstractSimplePredicate {
+public class ExplicitTruthValueCheck
+ extends AbstractSimplePredicate
+ implements Serializable {
// TODO : given that JPA supports only TRUE and FALSE, can this be handled just with negation?
private final Expression<Boolean> booleanExpression;
private final TruthValue truthValue;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,11 +39,13 @@
import org.hibernate.ejb.criteria.expression.LiteralExpression;
/**
- * TODO : javadoc
+ * Models an <tt>[NOT] IN</tt> restriction
*
* @author Steve Ebersole
*/
-public class InPredicate<T> extends AbstractSimplePredicate implements CriteriaBuilderImpl.In<T> {
+public class InPredicate<T>
+ extends AbstractSimplePredicate
+ implements CriteriaBuilderImpl.In<T>, Serializable {
private final Expression<? extends T> expression;
private final List<Expression<? extends T>> values;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import java.util.Collection;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -31,13 +32,13 @@
import org.hibernate.ejb.criteria.expression.UnaryOperatorExpression;
/**
- * TODO : javadoc
+ * Models an <tt>IS [NOT] EMPTY</tt> restriction
*
* @author Steve Ebersole
*/
public class IsEmptyPredicate<C extends Collection>
extends AbstractSimplePredicate
- implements UnaryOperatorExpression<Boolean> {
+ implements UnaryOperatorExpression<Boolean>, Serializable {
private final CollectionExpression<C> collectionExpression;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
@@ -35,7 +36,7 @@
*
* @author Steve Ebersole
*/
-public class LikePredicate extends AbstractSimplePredicate {
+public class LikePredicate extends AbstractSimplePredicate implements Serializable {
private final Expression<String> matchExpression;
private final Expression<String> pattern;
private final Expression<Character> escapeCharacter;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import java.util.Collection;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -33,12 +34,13 @@
import org.hibernate.ejb.criteria.expression.LiteralExpression;
/**
- * TODO : javadoc
+ * Models an <tt>[NOT] MEMBER OF</tt> restriction
*
* @author Steve Ebersole
*/
public class MemberOfPredicate<E, C extends Collection<E>>
- extends AbstractSimplePredicate {
+ extends AbstractSimplePredicate
+ implements Serializable {
private final Expression<E> elementExpression;
private final CollectionExpression<C> collectionExpression;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/NullnessPredicate.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -23,6 +23,7 @@
*/
package org.hibernate.ejb.criteria.predicate;
+import java.io.Serializable;
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.ParameterRegistry;
@@ -33,14 +34,16 @@
/**
* Defines a {@link javax.persistence.criteria.Predicate} for checking the
- * nullness state of an expression, aka an <tt>IS (NOT?) NULL</tt> predicate.
+ * nullness state of an expression, aka an <tt>IS [NOT] NULL</tt> predicate.
* <p/>
* The <tt>NOT NULL</tt> form can be built by calling the constructor and then
* calling {@link #not}.
*
* @author Steve Ebersole
*/
-public class NullnessPredicate extends AbstractSimplePredicate implements UnaryOperatorExpression<Boolean> {
+public class NullnessPredicate
+ extends AbstractSimplePredicate
+ implements UnaryOperatorExpression<Boolean>, Serializable {
private final Expression<?> operand;
/**
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java 2010-01-04 18:50:45 UTC (rev 18399)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java 2010-01-04 19:00:01 UTC (rev 18400)
@@ -139,8 +139,7 @@
root.fetch( "lineItems" );
criteria.select( root );
- // TODO uncomment the serialization line and enjoy the test failing
- // criteria = serializeDeserialize( criteria );
+ criteria = serializeDeserialize( criteria );
em.createQuery( criteria ).getResultList();
14 years, 11 months
Hibernate SVN: r18399 - in core/trunk/annotations/src: main/java/org/hibernate/cfg/annotations and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-01-04 13:50:45 -0500 (Mon, 04 Jan 2010)
New Revision: 18399
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/PropertyRecord.java
Log:
HHH-4752 support no prefix on @AttributeOverride and @ElementCollection (legacy "element" prefix used if @CollectionOfElements is used)
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -45,7 +45,7 @@
* @author Emmanuel Bernard
*/
public abstract class AbstractPropertyHolder implements PropertyHolder {
- protected PropertyHolder parent;
+ protected AbstractPropertyHolder parent;
private Map<String, Column[]> holderColumnOverride;
private Map<String, Column[]> currentPropertyColumnOverride;
private Map<String, JoinColumn[]> holderJoinColumnOverride;
@@ -57,7 +57,7 @@
String path, PropertyHolder parent, XClass clazzToProcess, ExtendedMappings mappings
) {
this.path = path;
- this.parent = parent;
+ this.parent = (AbstractPropertyHolder) parent;
this.mappings = mappings;
buildHierarchyColumnOverride( clazzToProcess );
}
@@ -98,39 +98,49 @@
/**
* Get column overriding, property first, then parent, then holder
- * replace
- * - "index" by "key" if present
- * - "element" by "value" if present
+ * replace the placeholder 'collection&&element' with nothing
+ *
* These rules are here to support both JPA 2 and legacy overriding rules.
*
- * WARNING: this can conflict with user's expectations if:
- * - the property uses some restricted values
- * - the user has overridden the column
- * But this is unlikely and avoid the need for a "legacy" flag
*/
public Column[] getOverriddenColumn(String propertyName) {
Column[] result = getExactOverriddenColumn( propertyName );
if (result == null) {
- if ( propertyName.contains( ".key." ) ) {
+ //the commented code can be useful if people use the new prefixes on old mappings and vice versa
+ // if we enable them:
+ // WARNING: this can conflict with user's expectations if:
+ // - the property uses some restricted values
+ // - the user has overridden the column
+
+// if ( propertyName.contains( ".key." ) ) {
+// //support for legacy @AttributeOverride declarations
+// //TODO cache the underlying regexp
+// result = getExactOverriddenColumn( propertyName.replace( ".key.", ".index." ) );
+// }
+// if ( result == null && propertyName.endsWith( ".key" ) ) {
+// //support for legacy @AttributeOverride declarations
+// //TODO cache the underlying regexp
+// result = getExactOverriddenColumn(
+// propertyName.substring( 0, propertyName.length() - ".key".length() ) + ".index"
+// );
+// }
+// if ( result == null && propertyName.contains( ".value." ) ) {
+// //support for legacy @AttributeOverride declarations
+// //TODO cache the underlying regexp
+// result = getExactOverriddenColumn( propertyName.replace( ".value.", ".element." ) );
+// }
+// if ( result == null && propertyName.endsWith( ".value" ) ) {
+// //support for legacy @AttributeOverride declarations
+// //TODO cache the underlying regexp
+// result = getExactOverriddenColumn(
+// propertyName.substring( 0, propertyName.length() - ".value".length() ) + ".element"
+// );
+// }
+ if ( result == null && propertyName.contains( ".collection&&element." ) ) {
+ //support for non map collections where no prefix is needed
//TODO cache the underlying regexp
- result = getExactOverriddenColumn( propertyName.replace( ".key.", ".index." ) );
+ result = getExactOverriddenColumn( propertyName.replace( ".collection&&element.", "." ) );
}
- if ( result == null && propertyName.endsWith( ".key" ) ) {
- //TODO cache the underlying regexp
- result = getExactOverriddenColumn(
- propertyName.substring( 0, propertyName.length() - ".key".length() ) + ".index"
- );
- }
- if ( result == null && propertyName.contains( ".value." ) ) {
- //TODO cache the underlying regexp
- result = getExactOverriddenColumn( propertyName.replace( ".value.", ".element." ) );
- }
- if ( result == null && propertyName.endsWith( ".value" ) ) {
- //TODO cache the underlying regexp
- result = getExactOverriddenColumn(
- propertyName.substring( 0, propertyName.length() - ".value".length() ) + ".element"
- );
- }
}
return result;
}
@@ -139,10 +149,10 @@
* Get column overriding, property first, then parent, then holder
* find the overridden rules from the exact property name.
*/
- private Column[] getExactOverriddenColumn(String propertyName) {
+ public Column[] getExactOverriddenColumn(String propertyName) {
Column[] override = null;
if ( parent != null ) {
- override = parent.getOverriddenColumn( propertyName );
+ override = parent.getExactOverriddenColumn( propertyName );
}
if ( override == null && currentPropertyColumnOverride != null ) {
override = currentPropertyColumnOverride.get( propertyName );
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/AnnotationBinder.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -1589,7 +1589,10 @@
CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder(
propertyHolder.getEntityName(),
property,
- !indexColumn.isImplicit()
+ !indexColumn.isImplicit(),
+ property.isAnnotationPresent( CollectionOfElements.class )
+ || property.isAnnotationPresent( org.hibernate.annotations.MapKey.class )
+ // || property.isAnnotationPresent( ManyToAny.class )
);
collectionBinder.setIndexColumn( indexColumn );
MapKey mapKeyAnn = property.getAnnotation( MapKey.class );
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -159,7 +159,20 @@
private XClass declaringClass;
private boolean declaringClassSet;
private AccessType accessType;
+ private boolean hibernateExtensionMapping;
+ public boolean isMap() {
+ return false;
+ }
+
+ public void setIsHibernateExtensionMapping(boolean hibernateExtensionMapping) {
+ this.hibernateExtensionMapping = hibernateExtensionMapping;
+ }
+
+ protected boolean isHibernateExtensionMapping() {
+ return hibernateExtensionMapping;
+ }
+
public void setUpdatable(boolean updatable) {
this.updatable = updatable;
}
@@ -224,14 +237,15 @@
*/
public static CollectionBinder getCollectionBinder(
String entityName, XProperty property,
- boolean isIndexed
+ boolean isIndexed, boolean isHibernateExtensionMapping
) {
+ CollectionBinder result;
if ( property.isArray() ) {
if ( property.getElementClass().isPrimitive() ) {
- return new PrimitiveArrayBinder();
+ result = new PrimitiveArrayBinder();
}
else {
- return new ArrayBinder();
+ result = new ArrayBinder();
}
}
else if ( property.isCollection() ) {
@@ -242,35 +256,35 @@
throw new AnnotationException( "Set do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- return new SetBinder();
+ result = new SetBinder();
}
else if ( java.util.SortedSet.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Set do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- return new SetBinder( true );
+ result = new SetBinder( true );
}
else if ( java.util.Map.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Map do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- return new MapBinder();
+ result = new MapBinder();
}
else if ( java.util.SortedMap.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Map do not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- return new MapBinder( true );
+ result = new MapBinder( true );
}
else if ( java.util.Collection.class.equals( returnedClass ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) {
- return new IdBagBinder();
+ result = new IdBagBinder();
}
else {
- return new BagBinder();
+ result = new BagBinder();
}
}
else if ( java.util.List.class.equals( returnedClass ) ) {
@@ -280,13 +294,13 @@
"List do not support @CollectionId and @OrderColumn (or @IndexColumn) at the same time: "
+ StringHelper.qualify( entityName, property.getName() ) );
}
- return new ListBinder();
+ result = new ListBinder();
}
else if ( property.isAnnotationPresent( CollectionId.class ) ) {
- return new IdBagBinder();
+ result = new IdBagBinder();
}
else {
- return new BagBinder();
+ result = new BagBinder();
}
}
else {
@@ -302,6 +316,8 @@
+ StringHelper.qualify( entityName, property.getName() )
);
}
+ result.setIsHibernateExtensionMapping( isHibernateExtensionMapping );
+ return result;
}
protected CollectionBinder() {
@@ -1251,10 +1267,7 @@
else {
XClass elementClass;
AnnotatedClassType classType;
-// Map<String, javax.persistence.Column[]> columnOverrides = PropertyHolderBuilder.buildColumnOverride(
-// property, StringHelper.qualify( collValue.getRole(), "element" )
-// );
- //FIXME the "element" is lost
+
PropertyHolder holder = null;
if ( BinderHelper.PRIMITIVE_NAMES.contains( collType.getName() ) ) {
classType = AnnotatedClassType.NONE;
@@ -1266,7 +1279,7 @@
holder = PropertyHolderBuilder.buildPropertyHolder(
collValue,
- collValue.getRole(), // + ".element",
+ collValue.getRole(),
elementClass,
property, parentPropertyHolder, mappings
);
@@ -1295,8 +1308,25 @@
throw new AssertionFailure( "Unable to guess collection property accessor name" );
}
- //"value" is the JPA 2 prefix for map values (used to be "element")
- PropertyData inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "value", elementClass );
+ PropertyData inferredData;
+ if ( isMap() ) {
+ //"value" is the JPA 2 prefix for map values (used to be "element")
+ if ( isHibernateExtensionMapping() ) {
+ inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass );
+ }
+ else {
+ inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "value", elementClass );
+ }
+ }
+ else {
+ if ( isHibernateExtensionMapping() ) {
+ inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass );
+ }
+ else {
+ //"collection&&element" is not a valid property name => placeholder
+ inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "collection&&element", elementClass );
+ }
+ }
//TODO be smart with isNullable
Component component = AnnotationBinder.fillComponent(
holder, inferredData, isPropertyAnnotated ? AccessType.PROPERTY : AccessType.FIELD, true,
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/annotations/MapBinder.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -83,6 +83,10 @@
super();
}
+ public boolean isMap() {
+ return true;
+ }
+
protected Collection createCollection(PersistentClass persistentClass) {
return new org.hibernate.mapping.Map( persistentClass );
}
@@ -222,9 +226,16 @@
throw new AssertionFailure( "Unable to guess collection property accessor name" );
}
- //boolean propertyAccess = embeddable == null || AccessType.PROPERTY.equals( embeddable.access() );
- //"key" is the JPA 2 prefix for map keys
- PropertyData inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "key", elementClass );
+
+ PropertyData inferredData;
+ if ( isHibernateExtensionMapping() ) {
+ inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "index", elementClass );
+ }
+ else {
+ //"key" is the JPA 2 prefix for map keys
+ inferredData = new PropertyPreloadedData( AccessType.PROPERTY, "key", elementClass );
+ }
+
//TODO be smart with isNullable
Component component = AnnotationBinder.fillComponent(
holder, inferredData, isPropertyAnnotated ? AccessType.PROPERTY : AccessType.FIELD, true,
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/embedded/WealthyPerson.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -27,5 +27,5 @@
@AttributeOverride(name="country",
column=@Column(name="HOME_COUNTRY"))
})
- protected Set<Address> vacationHomes = new HashSet();
+ protected Set<Address> vacationHomes = new HashSet<Address>();
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/AttributeOverrideTest.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -17,8 +17,22 @@
assertTrue( isColumnPresent( "PropertyRecord_parcels", "ASSESSMENT") );
assertTrue( isColumnPresent( "PropertyRecord_parcels", "SQUARE_FEET") );
assertTrue( isColumnPresent( "PropertyRecord_parcels", "STREET_NAME") );
+
+ //legacy mappings
+ assertTrue( isColumnPresent( "LegacyParcels", "ASSESSMENT") );
+ assertTrue( isColumnPresent( "LegacyParcels", "SQUARE_FEET") );
+ assertTrue( isColumnPresent( "LegacyParcels", "STREET_NAME") );
}
+ public void testElementCollection() throws Exception {
+ assertTrue( isColumnPresent( "PropertyRecord_unsortedParcels", "ASSESSMENT") );
+ assertTrue( isColumnPresent( "PropertyRecord_unsortedParcels", "SQUARE_FEET") );
+
+ //legacy mappings
+ assertTrue( isColumnPresent( "PropertyRecord_legacyUnsortedParcels", "ASSESSMENT") );
+ assertTrue( isColumnPresent( "PropertyRecord_legacyUnsortedParcels", "SQUARE_FEET") );
+ }
+
public boolean isColumnPresent(String tableName, String columnName) {
final Iterator<Table> tables = ( Iterator<Table> ) getCfg().getTableMappings();
while (tables.hasNext()) {
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/PropertyRecord.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/PropertyRecord.java 2010-01-04 18:16:42 UTC (rev 18398)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/override/PropertyRecord.java 2010-01-04 18:50:45 UTC (rev 18399)
@@ -1,6 +1,7 @@
package org.hibernate.test.annotations.override;
import java.util.Map;
+import java.util.Set;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
@@ -8,7 +9,11 @@
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.CollectionTable;
+import org.hibernate.annotations.MapKey;
+import org.hibernate.annotations.CollectionOfElements;
+
/**
* @author Emmanuel Bernard
*/
@@ -25,4 +30,28 @@
})
@ElementCollection
public Map<Address, PropertyInfo> parcels;
+
+ @AttributeOverrides({
+ @AttributeOverride(name = "index.street", column = @Column(name = "STREET_NAME")),
+ @AttributeOverride(name = "element.size", column = @Column(name = "SQUARE_FEET")),
+ @AttributeOverride(name = "element.tax", column = @Column(name = "ASSESSMENT"))
+ })
+ @CollectionOfElements
+ //@MapKey
+ @CollectionTable(name="LegacyParcels")
+ public Map<Address, PropertyInfo> legacyParcels;
+
+ @AttributeOverrides({
+ @AttributeOverride(name = "size", column = @Column(name = "SQUARE_FEET")),
+ @AttributeOverride(name = "tax", column = @Column(name = "ASSESSMENT"))
+ })
+ @ElementCollection
+ public Set<PropertyInfo> unsortedParcels;
+
+ @AttributeOverrides({
+ @AttributeOverride(name = "element.size", column = @Column(name = "SQUARE_FEET")),
+ @AttributeOverride(name = "element.tax", column = @Column(name = "ASSESSMENT"))
+ })
+ @CollectionOfElements
+ public Set<PropertyInfo> legacyUnsortedParcels;
}
\ No newline at end of file
14 years, 11 months
Hibernate SVN: r18398 - in core/trunk/entitymanager/src: main/java/org/hibernate/ejb/criteria and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-01-04 13:16:42 -0500 (Mon, 04 Jan 2010)
New Revision: 18398
Added:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImplementor.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java
Removed:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueConverter.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/AbstractEntityManagerImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernateEntityManagerImplementor.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaBuilderImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SelectionImplementor.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/TupleElementImplementor.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/QueryBuilderTest.java
Log:
HHH-4698 - Better handling of JPA criteria expressions
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -59,7 +59,7 @@
import org.hibernate.*;
import org.hibernate.cfg.Environment;
-import org.hibernate.ejb.criteria.ValueConverter;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
import org.hibernate.ejb.transaction.JoinableCMTTransaction;
import org.hibernate.ejb.util.ConfigurationHelper;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
@@ -148,8 +148,8 @@
Options options) {
try {
org.hibernate.Query hqlQuery = getSession().createQuery( jpaqlString );
- if ( options.getConversions() != null ) {
- hqlQuery.setResultTransformer( new ValueConversionResultTransformer( options.getConversions() ) );
+ if ( options.getValueHandlers() != null ) {
+ hqlQuery.setResultTransformer( new ValueConversionResultTransformer( options.getValueHandlers() ) );
}
else {
options.getResultMetadataValidator().validate( hqlQuery.getReturnTypes() );
@@ -162,20 +162,20 @@
}
private static class ValueConversionResultTransformer extends BasicTransformerAdapter {
- private List<ValueConverter.Conversion> conversions;
+ private List<ValueHandlerFactory.ValueHandler> valueHandlers;
- private ValueConversionResultTransformer(List<ValueConverter.Conversion> conversions) {
- this.conversions = conversions;
+ private ValueConversionResultTransformer(List<ValueHandlerFactory.ValueHandler> valueHandlers) {
+ this.valueHandlers = valueHandlers;
}
@Override
public Object transformTuple(Object[] tuple, String[] aliases) {
Object[] result = new Object[ tuple.length ];
for ( int i = 0; i < tuple.length; i++ ) {
- ValueConverter.Conversion conversion = conversions.get( i );
- result[i] = conversion == null
+ ValueHandlerFactory.ValueHandler valueHandler = valueHandlers.get( i );
+ result[i] = valueHandler == null
? tuple[i]
- : conversion.apply( tuple[i] );
+ : valueHandler.convert( tuple[i] );
}
return result.length == 1 ? result[0] : result;
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernateEntityManagerImplementor.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernateEntityManagerImplementor.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernateEntityManagerImplementor.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -30,8 +30,7 @@
import org.hibernate.HibernateException;
import org.hibernate.StaleStateException;
import org.hibernate.LockOptions;
-import org.hibernate.ejb.criteria.ValueConverter;
-import org.hibernate.transform.ResultTransformer;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
import org.hibernate.type.Type;
import java.util.List;
@@ -124,7 +123,7 @@
*
* @return Value conversions to be applied to the JPA QL results
*/
- public List<ValueConverter.Conversion> getConversions();
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers();
/**
* Get the explicit parameter types. Generally speaking these would apply to implicit named
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaBuilderImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaBuilderImpl.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaBuilderImpl.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -48,7 +48,6 @@
import org.hibernate.ejb.criteria.expression.CollectionExpression;
import org.hibernate.ejb.criteria.expression.CompoundSelectionImpl;
import org.hibernate.ejb.criteria.expression.ConcatExpression;
-import org.hibernate.ejb.criteria.ExpressionImplementor;
import org.hibernate.ejb.criteria.expression.ParameterExpressionImpl;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
import org.hibernate.ejb.criteria.expression.NullifExpression;
@@ -71,6 +70,7 @@
import org.hibernate.ejb.criteria.expression.function.SubstringFunction;
import org.hibernate.ejb.criteria.expression.function.TrimFunction;
import org.hibernate.ejb.criteria.expression.function.UpperFunction;
+import org.hibernate.ejb.criteria.predicate.BooleanAssertionPredicate;
import org.hibernate.ejb.criteria.predicate.BooleanExpressionPredicate;
import org.hibernate.ejb.criteria.predicate.NullnessPredicate;
import org.hibernate.ejb.criteria.predicate.CompoundPredicate;
@@ -252,6 +252,9 @@
if ( Predicate.class.isInstance( expression ) ) {
return ( ( Predicate ) expression );
}
+ else if ( PathImplementor.class.isInstance( expression ) ) {
+ return new BooleanAssertionPredicate( this, expression, Boolean.TRUE );
+ }
else {
return new BooleanExpressionPredicate( this, expression );
}
@@ -309,19 +312,15 @@
/**
* {@inheritDoc}
*/
- public Predicate isTrue(Expression<Boolean> x) {
- return wrap( x );
-// TODO : the correct thing here depends on response to #5 on my wiki page
-// return new ExplicitTruthValueCheck( this, x, TruthValue.TRUE );
+ public Predicate isTrue(Expression<Boolean> expression) {
+ return new BooleanAssertionPredicate( this, expression, Boolean.TRUE );
}
/**
* {@inheritDoc}
*/
- public Predicate isFalse(Expression<Boolean> x) {
- return wrap( x ).not();
-// TODO : the correct thing here depends on response to #5 on my wiki page
-// return new ExplicitTruthValueCheck( this, x, TruthValue.FALSE );
+ public Predicate isFalse(Expression<Boolean> expression) {
+ return new BooleanAssertionPredicate( this, expression, Boolean.FALSE );
}
/**
@@ -1122,10 +1121,11 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings({ "unchecked" })
public <Y> Expression<Y> all(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>(
this,
- (Class)subquery.getJavaType(),
+ (Class<Y>) subquery.getJavaType(),
subquery,
SubqueryComparisonModifierExpression.Modifier.ALL
);
@@ -1134,10 +1134,11 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings({ "unchecked" })
public <Y> Expression<Y> some(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>(
this,
- (Class)subquery.getJavaType(),
+ (Class<Y>) subquery.getJavaType(),
subquery,
SubqueryComparisonModifierExpression.Modifier.SOME
);
@@ -1146,10 +1147,11 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings({ "unchecked" })
public <Y> Expression<Y> any(Subquery<Y> subquery) {
return new SubqueryComparisonModifierExpression<Y>(
this,
- (Class)subquery.getJavaType(),
+ (Class<Y>) subquery.getJavaType(),
subquery,
SubqueryComparisonModifierExpression.Modifier.ANY
);
@@ -1161,8 +1163,9 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings({ "RedundantCast" })
public <Y> Expression<Y> coalesce(Expression<? extends Y> exp1, Expression<? extends Y> exp2) {
- return coalesce( (Class<Y>)null, exp1, exp2 );
+ return coalesce( (Class<Y>) null, exp1, exp2 );
}
public <Y> Expression<Y> coalesce(Class<Y> type, Expression<? extends Y> exp1, Expression<? extends Y> exp2) {
@@ -1172,8 +1175,9 @@
/**
* {@inheritDoc}
*/
+ @SuppressWarnings({ "RedundantCast" })
public <Y> Expression<Y> coalesce(Expression<? extends Y> exp1, Y exp2) {
- return coalesce( (Class<Y>)null, exp1, exp2 );
+ return coalesce( (Class<Y>) null, exp1, exp2 );
}
public <Y> Expression<Y> coalesce(Class<Y> type, Expression<? extends Y> exp1, Y exp2) {
@@ -1272,7 +1276,7 @@
return size( ( (LiteralExpression<C>) exp ).getLiteral() );
}
else if ( CollectionExpression.class.isInstance(exp) ) {
- return new SizeOfCollectionExpression<C>(this, null);
+ return new SizeOfCollectionExpression<C>(this, (CollectionExpression<C>) exp );
}
// TODO : what other specific types? any?
throw new IllegalArgumentException("unknown collection expression type [" + exp.getClass().getName() + "]" );
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryCompiler.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -38,6 +38,9 @@
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.ParameterExpression;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.hibernate.ejb.HibernateEntityManagerImplementor;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.type.Type;
@@ -54,6 +57,8 @@
* @author Steve Ebersole
*/
public class CriteriaQueryCompiler {
+ private static final Logger log = LoggerFactory.getLogger( CriteriaQueryCompiler.class );
+
public static interface ImplicitParameterBinding {
public String getParameterName();
public Class getJavaType();
@@ -72,7 +77,7 @@
public static interface RenderedCriteriaQuery {
public String getQueryString();
- public List<ValueConverter.Conversion> getValueConversions();
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers();
public HibernateEntityManagerImplementor.Options.ResultMetadataValidator getResultMetadataValidator();
}
@@ -143,12 +148,14 @@
final RenderedCriteriaQuery renderedCriteriaQuery = criteriaQueryImpl.render( renderingContext );
+ log.debug( "Rendered criteria query -> {}", renderedCriteriaQuery.getQueryString() );
+
TypedQuery<T> jpaqlQuery = entityManager.createQuery(
renderedCriteriaQuery.getQueryString(),
criteriaQuery.getResultType(),
new HibernateEntityManagerImplementor.Options() {
- public List<ValueConverter.Conversion> getConversions() {
- return renderedCriteriaQuery.getValueConversions();
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers() {
+ return renderedCriteriaQuery.getValueHandlers();
}
public Map<String, Class> getNamedParameterExplicitTypes() {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaQueryImpl.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -355,11 +355,11 @@
}
@SuppressWarnings({ "unchecked" })
- public List<ValueConverter.Conversion> getValueConversions() {
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers() {
SelectionImplementor selection = (SelectionImplementor) queryStructure.getSelection();
return selection == null
? null
- : selection.getConversions();
+ : selection.getValueHandlers();
}
public HibernateEntityManagerImplementor.Options.ResultMetadataValidator getResultMetadataValidator() {
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImplementor.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImplementor.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImplementor.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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 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.criteria.Path;
+import javax.persistence.metamodel.Attribute;
+
+/**
+ * Implementation contract for the JPA {@link Path} interface.
+ *
+ * @author Steve Ebersole
+ */
+public interface PathImplementor<X> extends ExpressionImplementor<X>, Path<X> {
+ /**
+ * Get the string representation of this path as a navigation from one of the
+ * queries <tt>identification variables</tt>
+ *
+ * @return The path's identifier.
+ */
+ public String getPathIdentifier();
+
+ /**
+ * Retrieve reference to the attribute this path represents.
+ *
+ * @return The metamodel attribute.
+ */
+ public Attribute<?, ?> getAttribute();
+}
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 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryStructure.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -207,7 +207,7 @@
public void render(StringBuilder jpaqlQuery, CriteriaQueryCompiler.RenderingContext renderingContext) {
jpaqlQuery.append( "select " );
if ( isDistinct() ) {
- jpaqlQuery.append( " distinct " );
+ jpaqlQuery.append( "distinct " );
}
if ( getSelection() == null ) {
// we should have only a single root (query validation should have checked this...)
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SelectionImplementor.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SelectionImplementor.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SelectionImplementor.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -32,5 +32,5 @@
* @author Steve Ebersole
*/
public interface SelectionImplementor<X> extends TupleElementImplementor<X>, Selection<X> {
- public List<ValueConverter.Conversion> getConversions();
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers();
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/TupleElementImplementor.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/TupleElementImplementor.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/TupleElementImplementor.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -31,5 +31,5 @@
* @author Steve Ebersole
*/
public interface TupleElementImplementor<X> extends TupleElement<X> {
- public ValueConverter.Conversion<X> getConversion();
+ public ValueHandlerFactory.ValueHandler<X> getValueHandler();
}
Deleted: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueConverter.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueConverter.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueConverter.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -1,269 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat Inc. 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 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.math.BigDecimal;
-import java.math.BigInteger;
-
-/**
- * Helper for generically converting a values into another type.
- *
- * @author Steve Ebersole
- */
-public class ValueConverter {
- private ValueConverter() {
- }
-
- public static interface Conversion<T> {
- public T apply(Object value);
- }
-
- public static boolean isNumeric(Class type) {
- return Number.class.isAssignableFrom( type )
- || Byte.TYPE.equals( type )
- || Short.TYPE.equals( type )
- || Integer.TYPE.equals( type )
- || Long.TYPE.isAssignableFrom( type )
- || Float.TYPE.equals( type )
- || Double.TYPE.isAssignableFrom( type );
- }
-
- public static class ByteConversion implements Conversion<Byte> {
- public static final ByteConversion INSTANCE = new ByteConversion();
- @SuppressWarnings({ "UnnecessaryBoxing" })
- public Byte apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return Byte.valueOf( ( (Number) value ).byteValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return Byte.valueOf( ( (String) value ) );
- }
- throw unknownConversion( value, Byte.class );
- }
- }
-
- public static class ShortConversion implements Conversion<Short> {
- public static final ShortConversion INSTANCE = new ShortConversion();
- @SuppressWarnings({ "UnnecessaryBoxing" })
- public Short apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return Short.valueOf( ( (Number) value ).shortValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return Short.valueOf( ( (String) value ) );
- }
- throw unknownConversion( value, Short.class );
- }
- }
-
- public static class IntegerConversion implements Conversion<Integer> {
- public static final IntegerConversion INSTANCE = new IntegerConversion();
- @SuppressWarnings({ "UnnecessaryBoxing" })
- public Integer apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return Integer.valueOf( ( (Number) value ).intValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return Integer.valueOf( ( (String) value ) );
- }
- throw unknownConversion( value, Integer.class );
- }
- }
-
- public static class LongConversion implements Conversion<Long> {
- public static final LongConversion INSTANCE = new LongConversion();
- @SuppressWarnings({ "UnnecessaryBoxing" })
- public Long apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return Long.valueOf( ( (Number) value ).longValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return Long.valueOf( ( (String) value ) );
- }
- throw unknownConversion( value, Long.class );
- }
- }
-
- public static class FloatConversion implements Conversion<Float> {
- public static final FloatConversion INSTANCE = new FloatConversion();
- @SuppressWarnings({ "UnnecessaryBoxing" })
- public Float apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return Float.valueOf( ( (Number) value ).floatValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return Float.valueOf( ( (String) value ) );
- }
- throw unknownConversion( value, Float.class );
- }
- }
-
- public static class DoubleConversion implements Conversion<Double> {
- public static final DoubleConversion INSTANCE = new DoubleConversion();
- @SuppressWarnings({ "UnnecessaryBoxing" })
- public Double apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return Double.valueOf( ( (Number) value ).doubleValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return Double.valueOf( ( (String) value ) );
- }
- throw unknownConversion( value, Double.class );
- }
- }
-
- public static class BigIntegerConversion implements Conversion<BigInteger> {
- public static final BigIntegerConversion INSTANCE = new BigIntegerConversion();
- public BigInteger apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( Number.class.isInstance( value ) ) {
- return BigInteger.valueOf( ( (Number) value ).longValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return new BigInteger( (String) value );
- }
- throw unknownConversion( value, BigInteger.class );
- }
- }
-
- public static class BigDecimalConversion implements Conversion<BigDecimal> {
- public static final BigDecimalConversion INSTANCE = new BigDecimalConversion();
- public BigDecimal apply(Object value) {
- if ( value == null ) {
- return null;
- }
- if ( BigInteger.class.isInstance( value ) ) {
- return new BigDecimal( (BigInteger) value );
- }
- else if ( Number.class.isInstance( value ) ) {
- return BigDecimal.valueOf( ( (Number) value ).doubleValue() );
- }
- else if ( String.class.isInstance( value ) ) {
- return new BigDecimal( (String) value );
- }
- throw unknownConversion( value, BigDecimal.class );
- }
- }
-
- public static class StringConversion implements Conversion<String> {
- public static final StringConversion INSTANCE = new StringConversion();
- public String apply(Object value) {
- return value == null ? null : value.toString();
- }
- }
-
- private static IllegalArgumentException unknownConversion(Object value, Class type) {
- return new IllegalArgumentException(
- "Unaware how to convert value [" + value + " : " + typeName( value ) + "] to requested type [" + type.getName() + "]"
- );
- }
-
- private static String typeName(Object value) {
- return value == null ? "???" : value.getClass().getName();
- }
-
- /**
- * Convert the given value into the specified target type.
- *
- * @param value The value to convert
- * @param targetType The type to which it should be converted
- *
- * @return The converted value.
- */
- @SuppressWarnings({ "unchecked" })
- public static <T> T convert(Object value, Class<T> targetType) {
- if ( value == null ) {
- return null;
- }
- if ( targetType.equals( value.getClass() ) ) {
- return (T) value;
- }
-
- Conversion<T> conversion = determineAppropriateConversion( targetType );
- if ( conversion == null ) {
- throw unknownConversion( value, targetType );
- }
- return conversion.apply( value );
- }
-
- /**
- * Determine the appropriate {@link Conversion} strategy for converting a value
- * to the given target type
- *
- * @param targetType The target type (to which we want to convert values).
- * @param <T> parameterized type for the target type.
- * @return The conversion
- */
- @SuppressWarnings({ "unchecked" })
- public static <T> Conversion<T> determineAppropriateConversion(Class<T> targetType) {
- if ( String.class.equals( targetType ) ) {
- return (Conversion<T>) StringConversion.INSTANCE;
- }
- if ( Byte.class.equals( targetType ) || Byte.TYPE.equals( targetType ) ) {
- return (Conversion<T>) ByteConversion.INSTANCE;
- }
- if ( Short.class.equals( targetType ) || Short.TYPE.equals( targetType ) ) {
- return (Conversion<T>) ShortConversion.INSTANCE;
- }
- if ( Integer.class.equals( targetType ) || Integer.TYPE.equals( targetType ) ) {
- return (Conversion<T>) IntegerConversion.INSTANCE;
- }
- if ( Long.class.equals( targetType ) || Long.TYPE.equals( targetType ) ) {
- return (Conversion<T>) LongConversion.INSTANCE;
- }
- if ( Float.class.equals( targetType ) || Float.TYPE.equals( targetType ) ) {
- return (Conversion<T>) FloatConversion.INSTANCE;
- }
- if ( Double.class.equals( targetType ) || Double.TYPE.equals( targetType ) ) {
- return (Conversion<T>) DoubleConversion.INSTANCE;
- }
- if ( BigInteger.class.equals( targetType ) ) {
- return (Conversion<T>) BigIntegerConversion.INSTANCE;
- }
- if ( BigDecimal.class.equals( targetType ) ) {
- return (Conversion<T>) BigDecimalConversion.INSTANCE;
- }
- return null;
- }
-}
Copied: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java (from rev 18312, core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueConverter.java)
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ValueHandlerFactory.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -0,0 +1,308 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Inc. 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 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.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * Helper for generically dealing with literal values.
+ *
+ * @author Steve Ebersole
+ */
+public class ValueHandlerFactory {
+ private ValueHandlerFactory() {
+ }
+
+ public static interface ValueHandler<T> {
+ public T convert(Object value);
+ public String render(T value);
+ }
+
+ public static abstract class BaseValueHandler<T> implements ValueHandler<T> {
+ public String render(T value) {
+ return value.toString();
+ }
+ }
+
+ public static class NoOpValueHandler<T> extends BaseValueHandler<T> {
+ @SuppressWarnings({ "unchecked" })
+ public T convert(Object value) {
+ return (T) value;
+ }
+ }
+
+ public static boolean isNumeric(Class type) {
+ return Number.class.isAssignableFrom( type )
+ || Byte.TYPE.equals( type )
+ || Short.TYPE.equals( type )
+ || Integer.TYPE.equals( type )
+ || Long.TYPE.equals( type )
+ || Float.TYPE.equals( type )
+ || Double.TYPE.equals( type );
+ }
+
+ public static boolean isNumeric(Object value) {
+ return Number.class.isInstance( value )
+ || Byte.TYPE.isInstance( value )
+ || Short.TYPE.isInstance( value )
+ || Integer.TYPE.isInstance( value )
+ || Long.TYPE.isInstance( value )
+ || Float.TYPE.isInstance( value )
+ || Double.TYPE.isInstance( value );
+ }
+
+ public static class ByteValueHandler extends BaseValueHandler<Byte> {
+ public static final ByteValueHandler INSTANCE = new ByteValueHandler();
+ @SuppressWarnings({ "UnnecessaryBoxing" })
+ public Byte convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return Byte.valueOf( ( (Number) value ).byteValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return Byte.valueOf( ( (String) value ) );
+ }
+ throw unknownConversion( value, Byte.class );
+ }
+ }
+
+ public static class ShortValueHandler extends BaseValueHandler<Short> {
+ public static final ShortValueHandler INSTANCE = new ShortValueHandler();
+ @SuppressWarnings({ "UnnecessaryBoxing" })
+ public Short convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return Short.valueOf( ( (Number) value ).shortValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return Short.valueOf( ( (String) value ) );
+ }
+ throw unknownConversion( value, Short.class );
+ }
+ }
+
+ public static class IntegerValueHandler extends BaseValueHandler<Integer> {
+ public static final IntegerValueHandler INSTANCE = new IntegerValueHandler();
+ @SuppressWarnings({ "UnnecessaryBoxing" })
+ public Integer convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return Integer.valueOf( ( (Number) value ).intValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return Integer.valueOf( ( (String) value ) );
+ }
+ throw unknownConversion( value, Integer.class );
+ }
+ }
+
+ public static class LongValueHandler extends BaseValueHandler<Long> {
+ public static final LongValueHandler INSTANCE = new LongValueHandler();
+ @SuppressWarnings({ "UnnecessaryBoxing" })
+ public Long convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return Long.valueOf( ( (Number) value ).longValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return Long.valueOf( ( (String) value ) );
+ }
+ throw unknownConversion( value, Long.class );
+ }
+
+ @Override
+ public String render(Long value) {
+ return value.toString() + 'L';
+ }
+ }
+
+ public static class FloatValueHandler extends BaseValueHandler<Float> {
+ public static final FloatValueHandler INSTANCE = new FloatValueHandler();
+ @SuppressWarnings({ "UnnecessaryBoxing" })
+ public Float convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return Float.valueOf( ( (Number) value ).floatValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return Float.valueOf( ( (String) value ) );
+ }
+ throw unknownConversion( value, Float.class );
+ }
+
+ @Override
+ public String render(Float value) {
+ return value.toString() + 'F';
+ }
+ }
+
+ public static class DoubleValueHandler extends BaseValueHandler<Double> {
+ public static final DoubleValueHandler INSTANCE = new DoubleValueHandler();
+ @SuppressWarnings({ "UnnecessaryBoxing" })
+ public Double convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return Double.valueOf( ( (Number) value ).doubleValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return Double.valueOf( ( (String) value ) );
+ }
+ throw unknownConversion( value, Double.class );
+ }
+
+ @Override
+ public String render(Double value) {
+ return value.toString() + 'D';
+ }
+ }
+
+ public static class BigIntegerValueHandler extends BaseValueHandler<BigInteger> {
+ public static final BigIntegerValueHandler INSTANCE = new BigIntegerValueHandler();
+ public BigInteger convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( Number.class.isInstance( value ) ) {
+ return BigInteger.valueOf( ( (Number) value ).longValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return new BigInteger( (String) value );
+ }
+ throw unknownConversion( value, BigInteger.class );
+ }
+ }
+
+ public static class BigDecimalValueHandler extends BaseValueHandler<BigDecimal> {
+ public static final BigDecimalValueHandler INSTANCE = new BigDecimalValueHandler();
+ public BigDecimal convert(Object value) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( BigInteger.class.isInstance( value ) ) {
+ return new BigDecimal( (BigInteger) value );
+ }
+ else if ( Number.class.isInstance( value ) ) {
+ return BigDecimal.valueOf( ( (Number) value ).doubleValue() );
+ }
+ else if ( String.class.isInstance( value ) ) {
+ return new BigDecimal( (String) value );
+ }
+ throw unknownConversion( value, BigDecimal.class );
+ }
+ }
+
+ public static class StringValueHandler extends BaseValueHandler<String> {
+ public static final StringValueHandler INSTANCE = new StringValueHandler();
+ public String convert(Object value) {
+ return value == null ? null : value.toString();
+ }
+ }
+
+ private static IllegalArgumentException unknownConversion(Object value, Class type) {
+ return new IllegalArgumentException(
+ "Unaware how to convert value [" + value + " : " + typeName( value ) + "] to requested type [" + type.getName() + "]"
+ );
+ }
+
+ private static String typeName(Object value) {
+ return value == null ? "???" : value.getClass().getName();
+ }
+
+ /**
+ * Convert the given value into the specified target type.
+ *
+ * @param value The value to convert
+ * @param targetType The type to which it should be converted
+ *
+ * @return The converted value.
+ */
+ @SuppressWarnings({ "unchecked" })
+ public static <T> T convert(Object value, Class<T> targetType) {
+ if ( value == null ) {
+ return null;
+ }
+ if ( targetType.equals( value.getClass() ) ) {
+ return (T) value;
+ }
+
+ ValueHandler<T> valueHandler = determineAppropriateHandler( targetType );
+ if ( valueHandler == null ) {
+ throw unknownConversion( value, targetType );
+ }
+ return valueHandler.convert( value );
+ }
+
+ /**
+ * Determine the appropriate {@link ValueHandlerFactory.ValueHandler} strategy for converting a value
+ * to the given target type
+ *
+ * @param targetType The target type (to which we want to convert values).
+ * @param <T> parameterized type for the target type.
+ * @return The conversion
+ */
+ @SuppressWarnings({ "unchecked" })
+ public static <T> ValueHandler<T> determineAppropriateHandler(Class<T> targetType) {
+ if ( String.class.equals( targetType ) ) {
+ return (ValueHandler<T>) StringValueHandler.INSTANCE;
+ }
+ if ( Byte.class.equals( targetType ) || Byte.TYPE.equals( targetType ) ) {
+ return (ValueHandler<T>) ByteValueHandler.INSTANCE;
+ }
+ if ( Short.class.equals( targetType ) || Short.TYPE.equals( targetType ) ) {
+ return (ValueHandler<T>) ShortValueHandler.INSTANCE;
+ }
+ if ( Integer.class.equals( targetType ) || Integer.TYPE.equals( targetType ) ) {
+ return (ValueHandler<T>) IntegerValueHandler.INSTANCE;
+ }
+ if ( Long.class.equals( targetType ) || Long.TYPE.equals( targetType ) ) {
+ return (ValueHandler<T>) LongValueHandler.INSTANCE;
+ }
+ if ( Float.class.equals( targetType ) || Float.TYPE.equals( targetType ) ) {
+ return (ValueHandler<T>) FloatValueHandler.INSTANCE;
+ }
+ if ( Double.class.equals( targetType ) || Double.TYPE.equals( targetType ) ) {
+ return (ValueHandler<T>) DoubleValueHandler.INSTANCE;
+ }
+ if ( BigInteger.class.equals( targetType ) ) {
+ return (ValueHandler<T>) BigIntegerValueHandler.INSTANCE;
+ }
+ if ( BigDecimal.class.equals( targetType ) ) {
+ return (ValueHandler<T>) BigDecimalValueHandler.INSTANCE;
+ }
+ return null;
+ }
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractTupleElement.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -26,7 +26,7 @@
import org.hibernate.ejb.criteria.AbstractNode;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.TupleElementImplementor;
-import org.hibernate.ejb.criteria.ValueConverter;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
/**
* TODO : javadoc
@@ -39,7 +39,7 @@
private final Class originalJavaType;
private Class<X> javaType;
private String alias;
- private ValueConverter.Conversion<X> conversion;
+ private ValueHandlerFactory.ValueHandler<X> valueHandler;
protected AbstractTupleElement(CriteriaBuilderImpl criteriaBuilder, Class<X> javaType) {
super( criteriaBuilder );
@@ -57,21 +57,21 @@
@SuppressWarnings({ "unchecked" })
protected void resetJavaType(Class targetType) {
this.javaType = targetType;
-// this.conversion = javaType.equals( originalJavaType )
+// this.valueHandler = javaType.equals( originalJavaType )
// ? null
-// : ValueConverter.determineAppropriateConversion( javaType );
- this.conversion = ValueConverter.determineAppropriateConversion( javaType );
+// : ValueHandlerFactory.determineAppropriateHandler( javaType );
+ this.valueHandler = ValueHandlerFactory.determineAppropriateHandler( javaType );
}
- protected void forceConversion(ValueConverter.Conversion<X> conversion) {
- this.conversion = conversion;
+ protected void forceConversion(ValueHandlerFactory.ValueHandler<X> valueHandler) {
+ this.valueHandler = valueHandler;
}
/**
* {@inheritDoc}
*/
- public ValueConverter.Conversion<X> getConversion() {
- return conversion;
+ public ValueHandlerFactory.ValueHandler<X> getValueHandler() {
+ return valueHandler;
}
/**
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/BinaryArithmeticOperation.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -67,7 +67,8 @@
},
MOD {
String apply(String lhs, String rhs) {
- return lhs + " % " + rhs;
+// return lhs + " % " + rhs;
+ return "mod(" + lhs + "," + rhs + ")";
}
};
abstract String apply(String lhs, String rhs);
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CompoundSelectionImpl.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -34,7 +34,7 @@
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.TupleElementImplementor;
-import org.hibernate.ejb.criteria.ValueConverter;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
/**
* The Hibernate implementation of the JPA {@link CompoundSelection}
@@ -66,18 +66,18 @@
}
@Override
- public List<ValueConverter.Conversion> getConversions() {
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers() {
if ( isConstructor ) {
return null;
}
- boolean foundConversions = false;
- ArrayList<ValueConverter.Conversion> conversions = new ArrayList<ValueConverter.Conversion>();
+ boolean foundHandlers = false;
+ ArrayList<ValueHandlerFactory.ValueHandler> valueHandlers = new ArrayList<ValueHandlerFactory.ValueHandler>();
for ( Selection selection : getCompoundSelectionItems() ) {
- ValueConverter.Conversion conversion = ( (TupleElementImplementor) selection ).getConversion();
- conversions.add( conversion );
- foundConversions = foundConversions || conversion != null;
+ ValueHandlerFactory.ValueHandler valueHandler = ( (TupleElementImplementor) selection ).getValueHandler();
+ valueHandlers.add( valueHandler );
+ foundHandlers = foundHandlers || valueHandler != null;
}
- return foundConversions ? null : conversions;
+ return foundHandlers ? null : valueHandlers;
}
public void registerParameters(ParameterRegistry registry) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -25,7 +25,7 @@
import javax.persistence.TypedQuery;
-import org.hibernate.ejb.criteria.ValueConverter;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
@@ -61,7 +61,13 @@
// nothing to do
}
+ @SuppressWarnings({ "unchecked" })
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ if ( ValueHandlerFactory.isNumeric( literal ) ) {
+ return ValueHandlerFactory.determineAppropriateHandler( (Class) literal.getClass() ).render( literal );
+ }
+
+ // else...
final String parameterName = renderingContext.generateParameterName();
renderingContext.registerImplicitParameterBinding(
new CriteriaQueryCompiler.ImplicitParameterBinding() {
@@ -89,14 +95,14 @@
@SuppressWarnings({ "unchecked" })
protected void resetJavaType(Class targetType) {
super.resetJavaType( targetType );
- ValueConverter.Conversion conversion = getConversion();
- if ( conversion == null ) {
- conversion = ValueConverter.determineAppropriateConversion( targetType );
- forceConversion( conversion );
+ ValueHandlerFactory.ValueHandler valueHandler = getValueHandler();
+ if ( valueHandler == null ) {
+ valueHandler = ValueHandlerFactory.determineAppropriateHandler( targetType );
+ forceConversion( valueHandler );
}
- if ( conversion != null ) {
- literal = conversion.apply( literal );
+ if ( valueHandler != null ) {
+ literal = valueHandler.convert( literal );
}
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SelectionImpl.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -30,7 +30,7 @@
import org.hibernate.ejb.criteria.ParameterContainer;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.SelectionImplementor;
-import org.hibernate.ejb.criteria.ValueConverter;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
/**
* The Hibernate implementation of the JPA {@link Selection}
@@ -54,13 +54,13 @@
return false;
}
- public List<ValueConverter.Conversion> getConversions() {
- return getConversion() == null
+ public List<ValueHandlerFactory.ValueHandler> getValueHandlers() {
+ return getValueHandler() == null
? null
- : Collections.singletonList( (ValueConverter.Conversion) getConversion() );
+ : Collections.singletonList( (ValueHandlerFactory.ValueHandler) getValueHandler() );
}
public List<Selection<?>> getCompoundSelectionItems() {
- throw new IllegalStateException( "Not a compund selection" );
+ throw new IllegalStateException( "Not a compound selection" );
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/SizeOfCollectionExpression.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -50,11 +50,11 @@
}
public void registerParameters(ParameterRegistry registry) {
- // nothign to do
+ // nothing to do
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return "size of " + getCollectionExpression().render( renderingContext );
+ return "size(" + getCollectionExpression().render( renderingContext ) + ")";
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AggregationFunction.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -25,6 +25,7 @@
import javax.persistence.criteria.Expression;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
+import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
/**
@@ -87,6 +88,14 @@
this.distinct = distinct;
}
+ @Override
+ protected void renderArguments(StringBuilder buffer, CriteriaQueryCompiler.RenderingContext renderingContext) {
+ if ( isDistinct() ) {
+ buffer.append( "distinct " );
+ }
+ super.renderArguments( buffer, renderingContext );
+ }
+
public boolean isDistinct() {
return distinct;
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/ParameterizedFunctionExpression.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -91,12 +91,15 @@
@Override
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
StringBuilder buffer = new StringBuilder();
- buffer.append( getFunctionName() )
- .append( '(' );
+ buffer.append( getFunctionName() ).append( '(' );
+ renderArguments( buffer, renderingContext );
+ buffer.append( ')' );
+ return buffer.toString();
+ }
+
+ protected void renderArguments(StringBuilder buffer, CriteriaQueryCompiler.RenderingContext renderingContext) {
for ( Expression argument : argumentExpressions ) {
buffer.append( ( (Renderable) argument ).render( renderingContext ) );
}
- buffer.append( ')' );
- return buffer.toString();
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BetweenPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -83,8 +83,9 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ final String operator = isNegated() ? " not between " : " between ";
return ( (Renderable) getExpression() ).render( renderingContext )
- + " between "
+ + operator
+ ( (Renderable) getLowerBound() ).render( renderingContext )
+ " and "
+ ( (Renderable) getUpperBound() ).render( renderingContext );
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/BooleanAssertionPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -0,0 +1,85 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. 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 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.predicate;
+
+import javax.persistence.criteria.Expression;
+
+import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
+import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.ParameterRegistry;
+import org.hibernate.ejb.criteria.Renderable;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class BooleanAssertionPredicate extends AbstractSimplePredicate {
+ private final Expression<Boolean> expression;
+ private final Boolean assertedValue;
+
+ public BooleanAssertionPredicate(
+ CriteriaBuilderImpl criteriaBuilder,
+ Expression<Boolean> expression,
+ Boolean assertedValue) {
+ super( criteriaBuilder );
+ this.expression = expression;
+ this.assertedValue = assertedValue;
+ }
+
+ public Expression<Boolean> getExpression() {
+ return expression;
+ }
+
+ public Boolean getAssertedValue() {
+ return assertedValue;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerParameters(ParameterRegistry registry) {
+ Helper.possibleParameter( expression, registry );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ final String operator = isNegated() ? " = " : " <> ";
+ final String assertionLiteral = assertedValue ? "true" : "false";
+
+ return ( (Renderable) expression ).render( renderingContext )
+ + operator
+ + assertionLiteral;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ return render( renderingContext );
+ }
+
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/ComparisonPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -25,7 +25,7 @@
import javax.persistence.criteria.Expression;
-import org.hibernate.ejb.criteria.ValueConverter;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
@@ -63,10 +63,10 @@
super( criteriaBuilder );
this.comparisonOperator = comparisonOperator;
this.leftHandSide = leftHandSide;
- if ( ValueConverter.isNumeric( leftHandSide.getJavaType() ) ) {
+ if ( ValueHandlerFactory.isNumeric( leftHandSide.getJavaType() ) ) {
this.rightHandSide = new LiteralExpression(
criteriaBuilder,
- ValueConverter.convert( rightHandSide, (Class<Number>) leftHandSide.getJavaType() )
+ ValueHandlerFactory.convert( rightHandSide, (Class<Number>) leftHandSide.getJavaType() )
);
}
else {
@@ -84,7 +84,7 @@
this.leftHandSide = leftHandSide;
this.rightHandSide = new LiteralExpression<N>(
criteriaBuilder,
- ValueConverter.convert( rightHandSide, leftHandSide.getJavaType() )
+ ValueHandlerFactory.convert( rightHandSide, leftHandSide.getJavaType() )
);
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/CompoundPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -35,7 +35,7 @@
import org.hibernate.ejb.criteria.Renderable;
/**
- * A compound {@link Predicate predicate} is a grouping of other {@link Predicate predicates} in order to apply
+ * A compound {@link Predicate predicate} is a grouping of other {@link Predicate predicates} in order to convert
* either a conjunction (logical AND) or a disjunction (logical OR).
*
* @author Steve Ebersole
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/InPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -34,6 +34,7 @@
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
import org.hibernate.ejb.criteria.Renderable;
+import org.hibernate.ejb.criteria.ValueHandlerFactory;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
/**
@@ -114,10 +115,14 @@
Collection<T> values) {
super( criteriaBuilder );
this.expression = expression;
- // TODO : size this?
- this.values = new ArrayList<Expression<? extends T>>();
+ this.values = new ArrayList<Expression<? extends T>>( values.size() );
+ ValueHandlerFactory.ValueHandler<? extends T> valueHandler = ValueHandlerFactory.isNumeric( expression.getJavaType() )
+ ? ValueHandlerFactory.determineAppropriateHandler( (Class<? extends T>) expression.getJavaType() )
+ : new ValueHandlerFactory.NoOpValueHandler<T>();
for ( T value : values ) {
- this.values.add( new LiteralExpression<T>( criteriaBuilder, value ) );
+ this.values.add(
+ new LiteralExpression<T>( criteriaBuilder, valueHandler.convert( value ) )
+ );
}
}
@@ -151,10 +156,17 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- StringBuilder buffer = new StringBuilder( "in" );
+ StringBuilder buffer = new StringBuilder();
- // subquery expressions are already wrapped in parenthesis, so we only
- // need to render the parens here if the values represent an explicit value list
+ buffer.append( ( (Renderable) getExpression() ).render( renderingContext ) );
+
+ if ( isNegated() ) {
+ buffer.append( " not" );
+ }
+ buffer.append( " in " );
+
+ // subquery expressions are already wrapped in parenthesis, so we only need to
+ // render the parenthesis here if the values represent an explicit value list
boolean isInSubqueryPredicate = getValues().size() == 1
&& Subquery.class.isInstance( getValues().get( 0 ) );
if ( isInSubqueryPredicate ) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/IsEmptyPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -57,7 +57,8 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return getOperand().render( renderingContext ) + " is empty";
+ final String operator = isNegated() ? " is not empty" : " is empty";
+ return getOperand().render( renderingContext ) + operator;
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/LikePredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -123,15 +123,16 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- StringBuilder likeExpr = new StringBuilder();
- likeExpr.append( ( (Renderable) getMatchExpression() ).render( renderingContext ) )
- .append( " like " )
+ final String operator = isNegated() ? " not like " : " like ";
+ StringBuilder buffer = new StringBuilder();
+ buffer.append( ( (Renderable) getMatchExpression() ).render( renderingContext ) )
+ .append( operator )
.append( ( (Renderable) getPattern() ).render( renderingContext ) );
if ( escapeCharacter != null ) {
- likeExpr.append( " escape " )
+ buffer.append( " escape " )
.append( ( (Renderable) getEscapeCharacter() ).render( renderingContext ) );
}
- return likeExpr.toString();
+ return buffer.toString();
}
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/MemberOfPredicate.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -28,6 +28,7 @@
import org.hibernate.ejb.criteria.ParameterRegistry;
import org.hibernate.ejb.criteria.CriteriaBuilderImpl;
import org.hibernate.ejb.criteria.CriteriaQueryCompiler;
+import org.hibernate.ejb.criteria.Renderable;
import org.hibernate.ejb.criteria.expression.CollectionExpression;
import org.hibernate.ejb.criteria.expression.LiteralExpression;
@@ -76,7 +77,8 @@
}
public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
- return ( isNegated() ? "not " : "" ) + "member of "
+ return ( (Renderable) elementExpression ).render( renderingContext )
+ + ( isNegated() ? " not" : "" ) + " member of "
+ collectionExpression.render( renderingContext );
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/CriteriaCompilingTest.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -23,21 +23,31 @@
*/
package org.hibernate.ejb.criteria;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
+import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Join;
+import org.hibernate.ejb.metamodel.Address;
+import org.hibernate.ejb.metamodel.Alias;
+import org.hibernate.ejb.metamodel.Country;
+import org.hibernate.ejb.metamodel.CreditCard;
+import org.hibernate.ejb.metamodel.Customer;
+import org.hibernate.ejb.metamodel.Info;
+import org.hibernate.ejb.metamodel.LineItem;
+import org.hibernate.ejb.metamodel.Order;
+import org.hibernate.ejb.metamodel.Phone;
+import org.hibernate.ejb.metamodel.Product;
+import org.hibernate.ejb.metamodel.ShelfLife;
+import org.hibernate.ejb.metamodel.Spouse;
import org.hibernate.ejb.test.TestCase;
+import org.hibernate.ejb.test.callbacks.RemoteControl;
+import org.hibernate.ejb.test.callbacks.Television;
import org.hibernate.ejb.test.callbacks.VideoSystem;
-import org.hibernate.ejb.test.callbacks.Television;
-import org.hibernate.ejb.test.callbacks.RemoteControl;
import org.hibernate.ejb.test.inheritance.Fruit;
import org.hibernate.ejb.test.inheritance.Strawberry;
@@ -50,9 +60,17 @@
public Class[] getAnnotatedClasses() {
return new Class[] {
Customer.class,
- Item.class,
+ Alias.class,
+ Phone.class,
+ Address.class,
+ Country.class,
+ CreditCard.class,
+ Info.class,
+ Spouse.class,
+ LineItem.class,
Order.class,
Product.class,
+ ShelfLife.class,
// @Inheritance
Fruit.class,
Strawberry.class,
@@ -112,7 +130,6 @@
em.close();
}
- //FIXME uncomment the serialization line and enjoy the test failing
public void testSerialization() {
EntityManager em = getOrCreateEntityManager();
em.getTransaction().begin();
@@ -122,8 +139,8 @@
root.fetch( "lineItems" );
criteria.select( root );
- //FIXME uncomment the serialization line and enjoy the test failing
- //criteria = serializeDdeserialize( criteria );
+ // TODO uncomment the serialization line and enjoy the test failing
+ // criteria = serializeDeserialize( criteria );
em.createQuery( criteria ).getResultList();
@@ -131,7 +148,7 @@
em.close();
}
- private <T> T serializeDdeserialize(T object) {
+ private <T> T serializeDeserialize(T object) {
T serializedObject = null;
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Deleted: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Customer.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -1,79 +0,0 @@
-/*
- * 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;
- }
-}
Deleted: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Item.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -1,78 +0,0 @@
-/*
- * 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;
- }
-}
Deleted: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Order.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -1,84 +0,0 @@
-/*
- * 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;
- }
-}
Deleted: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/Product.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -1,80 +0,0 @@
-/*
- * 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;
- }
-}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/QueryBuilderTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/QueryBuilderTest.java 2010-01-04 18:11:07 UTC (rev 18397)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/QueryBuilderTest.java 2010-01-04 18:16:42 UTC (rev 18398)
@@ -23,12 +23,15 @@
*/
package org.hibernate.ejb.criteria;
-import java.util.List;
+import java.util.Collection;
+import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.PluralAttribute;
import org.hibernate.ejb.criteria.predicate.ComparisonPredicate;
import org.hibernate.ejb.metamodel.Address;
@@ -36,6 +39,7 @@
import org.hibernate.ejb.metamodel.Country;
import org.hibernate.ejb.metamodel.CreditCard;
import org.hibernate.ejb.metamodel.Customer;
+import org.hibernate.ejb.metamodel.Customer_;
import org.hibernate.ejb.metamodel.Info;
import org.hibernate.ejb.metamodel.LineItem;
import org.hibernate.ejb.metamodel.Order;
14 years, 11 months
Hibernate SVN: r18397 - search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/jms/master.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-04 13:11:07 -0500 (Mon, 04 Jan 2010)
New Revision: 18397
Modified:
search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java
Log:
JBPAPP-3078 Test JMSMasterTest contains invalid SQL statement
Modified: search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java
===================================================================
--- search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java 2010-01-04 18:09:56 UTC (rev 18396)
+++ search/branches/Branch_3_0_1_GA_CP/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java 2010-01-04 18:11:07 UTC (rev 18397)
@@ -44,7 +44,7 @@
Session s = openSession( );
s.getTransaction().begin();
s.connection().createStatement().executeUpdate(
- "insert into TShirt_Master(id, logo, size) values( '1', 'JBoss balls', 'large')"
+ "insert into TShirt_Master(id, logo, size) values( 1, 'JBoss balls', 'large')"
);
TShirt ts = (TShirt) s.get(TShirt.class, 1);
s.getTransaction().commit();
14 years, 11 months
Hibernate SVN: r18396 - search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/jms/master.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-04 13:09:56 -0500 (Mon, 04 Jan 2010)
New Revision: 18396
Modified:
search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java
Log:
JBPAPP-3078 Test JMSMasterTest contains invalid SQL statement
Modified: search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java
===================================================================
--- search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java 2010-01-04 17:56:33 UTC (rev 18395)
+++ search/branches/v3_1_1_GA_CP/src/test/java/org/hibernate/search/test/jms/master/JMSMasterTest.java 2010-01-04 18:09:56 UTC (rev 18396)
@@ -146,7 +146,7 @@
s.getTransaction().begin();
Statement statement = s.connection().createStatement();
statement.executeUpdate(
- "insert into TShirt_Master(id, logo, size_) values( '1', 'JBoss balls', 'large')"
+ "insert into TShirt_Master(id, logo, size_) values( 1, 'JBoss balls', 'large')"
);
statement.close();
TShirt ts = ( TShirt ) s.get( TShirt.class, 1 );
14 years, 11 months
Hibernate SVN: r18395 - core/branches/Branch_3_2_4_SP1_CP.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-04 12:56:33 -0500 (Mon, 04 Jan 2010)
New Revision: 18395
Modified:
core/branches/Branch_3_2_4_SP1_CP/
Log:
add eclipse metadata files to the ignore list
Property changes on: core/branches/Branch_3_2_4_SP1_CP
___________________________________________________________________
Name: svn:ignore
- build
target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
+ build
target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
.settings
14 years, 11 months
Hibernate SVN: r18394 - search/branches/Branch_3_0_1_GA_CP.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-01-04 12:55:01 -0500 (Mon, 04 Jan 2010)
New Revision: 18394
Modified:
search/branches/Branch_3_0_1_GA_CP/
Log:
add eclipse metadata files to the ignore list
Property changes on: search/branches/Branch_3_0_1_GA_CP
___________________________________________________________________
Name: svn:ignore
- build
indextemp
lucenedirs
target
test_output
+ build
indextemp
lucenedirs
target
test_output
.classpath
.project
14 years, 11 months