openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Reverse Mapping PostgresDB - unique constraints not generated.
Date Wed, 01 Jun 2011 14:42:30 GMT
John -

I can't say for certain that this has ever worked... let me know if you come
up with something!

Thanks,
Rick

On Wed, Jun 1, 2011 at 4:09 AM, Boblitz John <John.Boblitz@bertschi.com>wrote:

> Hello Chris,
>
> Thanks for the tip.
>
> I tried both <unique ... > and <uniqueindex ... > but the results
> were the same.
>
> Any idea if this has ever worked in the past?
>
> John
>
> -----Ursprüngliche Nachricht-----
> Von: Rick Curtis [mailto:curtisr7@gmail.com]
> Gesendet: Dienstag, 31. Mai 2011 16:09
> An: users@openjpa.apache.org
> Betreff: Re: Reverse Mapping PostgresDB - unique constraints not generated.
>
> John -
>
> I have a shot in the dark for you... Try changing <index name="...." to
> <unique name="...."
>
> On Mon, May 23, 2011 at 1:30 AM, Boblitz John <John.Boblitz@bertschi.com
> >wrote:
>
> > Good Morning,
> >
> > I wont spam the list with this, but I am reposting once in hopes of
> > getting an answer ....
> >
> > So, last time asking, please forgive the shameless repost!
> >
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Boblitz John [mailto:John.Boblitz@BERTSCHI.com]
> > Gesendet: Freitag, 20. Mai 2011 08:26
> > An: users@openjpa.apache.org
> > Betreff: Reverse Mapping PostgresDB - unique constraints not generated.
> >
> > Hello,
> >
> > 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 not 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" size="5"/>
> >    <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"
> column="tocurrency"/>
> >    <fk name="fk_currency_of_exchange_rate_fromcurrency"
> > delete-action="restrict" to-table="galaxy11.currency"
> > column="fromcurrency"/>
> >    <index name="uq_exchangerate_type_to_from_begin" unique="true">
> >      <on column="type"/>
> >      <on column="tocurrency"/>
> >      <on column="fromcurrency"/>
> >      <on column="begin"/>
> >    </index>
> >    <index name="uq_exchangerate_uniqueid" unique="true"
> > column="uniqueid"/> </table>
> >
> >
> >
> > ======================================================================
> > =====================================================================
> >
> > 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
> >  */
> > @Entity
> > @Table(schema="galaxy11", name="exchangerate")
> > @IdClass(g11.persistence.model.ExchangerateId.class)
> > public class Exchangerate {
> >
> >        @Basic
> >        @Column(nullable=false)
> >        @Temporal(TemporalType.DATE)
> >        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;
> >
> >        @Basic
> >        @Column(columnDefinition="int2")
> >        private short modifier;
> >
> >        @Basic
> >        private double rate;
> >
> >        @Basic
> >        @Column(columnDefinition="bpchar", nullable=false, length=2)
> >        private String type;
> >
> >        @Id
> >        @Column(columnDefinition="int8")
> >        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?
> >
> > Specs:
> >
> >        openJPA 2.1.0
> >        postgresql-8.4-702.jdbc4.jar
> >
> >        On Eclipse Helios
> >
> >
> > Thanks.
> >
> > 
> >
> > John
> >
> > ----
> >
> > Who is General Failure, and why is he reading my hard disk?
> >
> >
> >
> >
>
>
> --
> *Rick Curtis*
>



-- 
*Rick Curtis*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message