openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boblitz John" <>
Subject Reverse Mapping PostgresDB - unique constraints not generated.
Date Fri, 20 May 2011 06:26:00 GMT
I am attempted to reverse map a PostgresDB, and, after some initial problems
I suceeded in generating a schema with the SchemaTool and then the annotated classes
via the ReverseMappingTool.
I am generally very happy with the results.  However, none of my unique constraints are
annotated in the classes!  The data regarding the constrainst is in the schema.xml - but does
get used.
I searched the list and extensively on the net, but most of what I find has nothing to do
with the 
problem ...

Here an example from the schema.xml:
<table name="exchangerate">
  <pk name="pk_exchangerate" column="uniqueid"/>
    <column name="uniqueid" type="bigint" type-name="int8" not-null="true" size="19"/>
    <column name="type" type="char" type-name="bpchar" not-null="true" size="2"/>
    <column name="fromcurrency" type="bigint" type-name="int8" not-null="true" size="19"/>
    <column name="tocurrency" type="bigint" type-name="int8" not-null="true" size="19"/>
    <column name="begin" type="date" not-null="true" size="13"/>
    <column name="modifier" type="smallint" type-name="int2" not-null="true" default="1"
    <column name="rate" type="numeric" not-null="true" size="10" decimal-digits="5"/>
    <fk name="fk_currency_of_exchange_rate_tocurrency" delete-action="restrict" to-table="galaxy11.currency"
    <fk name="fk_currency_of_exchange_rate_fromcurrency" delete-action="restrict" to-table="galaxy11.currency"
    <index name="uq_exchangerate_type_to_from_begin" unique="true">
      <on column="type"/>
      <on column="tocurrency"/>
      <on column="fromcurrency"/>
      <on column="begin"/>
    <index name="uq_exchangerate_uniqueid" unique="true" column="uniqueid"/>


And here, the generated class:  the Unique Constraint "uq_exchangerate_type_to_from_begin"
is missing ....

package g11.persistence.model;

import java.util.*;
import javax.persistence.*;

 * Auto-generated by:
 * org.apache.openjpa.jdbc.meta.ReverseMappingTool$AnnotatedCodeGenerator
@Table(schema="galaxy11", name="exchangerate")
public class Exchangerate {

	private Date begin;

	@ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
	@JoinColumn(name="fromcurrency", columnDefinition="int8", nullable=false)
	private Currency fkCurrencyOfExchangeRateFromcurrency;

	@ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE)
	@JoinColumn(name="tocurrency", columnDefinition="int8", nullable=false)
	private Currency fkCurrencyOfExchangeRateTocurrency;

	private short modifier;

	private double rate;

	@Column(columnDefinition="bpchar", nullable=false, length=2)
	private String type;

	private long uniqueid;

	public Exchangerate () {

	public Exchangerate (long uniqueid) {
		this.uniqueid = uniqueid;

	public Date getBegin () {
		return begin;

	public void setBegin (Date begin) {
		this.begin = begin;

	public Currency getFkCurrencyOfExchangeRateFromcurrency () {
		return fkCurrencyOfExchangeRateFromcurrency;

	public void setFkCurrencyOfExchangeRateFromcurrency (Currency fkCurrencyOfExchangeRateFromcurrency)
		this.fkCurrencyOfExchangeRateFromcurrency = fkCurrencyOfExchangeRateFromcurrency;

	public Currency getFkCurrencyOfExchangeRateTocurrency () {
		return fkCurrencyOfExchangeRateTocurrency;

	public void setFkCurrencyOfExchangeRateTocurrency (Currency fkCurrencyOfExchangeRateTocurrency)
		this.fkCurrencyOfExchangeRateTocurrency = fkCurrencyOfExchangeRateTocurrency;

	public short getModifier () {
		return modifier;

	public void setModifier (short modifier) {
		this.modifier = modifier;

	public double getRate () {
		return rate;

	public void setRate (double rate) {
		this.rate = rate;

	public String getType () {
		return type;

	public void setType (String type) {
		this.type = type;

	public long getUniqueid () {
		return uniqueid;

	public void setUniqueid (long uniqueid) {
		this.uniqueid = uniqueid;

I expected:

@Table(schema="galaxy11", name="exchangerate" uniqueConstraints=@Unique(columnNames={"type",
"tocurrency", "fromcurrency", "begin"})

Is this a known problem?  Any way to get the results I'm looking for?


	openJPA 2.1.0
	On Eclipse Helios




Who is General Failure, and why is he reading my hard disk?

View raw message