-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problems with mapping a view
PostPosted: Wed Feb 27, 2008 2:13 pm 
Newbie

Joined: Wed Feb 27, 2008 1:55 pm
Posts: 3
Location: Germany
Hi,

I'm trying to map a Oracle 10 View with Hibernate 3.2.6.

I've created an Entity class with the same name as the View in Oracle - but while starting the JBoss App Server Hibernate still trys to create a table.

Probably i'm using the wrong datatypes in my Entity class - can you please check the Oracle View and my Entity class?

Thanks a lot!

altes-kind

Code:
19:01:36,922 INFO  [DatabaseMetadata] table not found: VTERMINGELDER2
.
.
.
19:01:37,625 ERROR [SchemaUpdate] Unsuccessful: create table VTERMINGELDER2 (KONTONUMMER number(10,0) not null, KUNDENNUMMER number(10,0), SOLLZINS char(1 char), INTERESTRATE float, ANLAGEFRIST number(5,0), ANLAGEVOLUMEN double precision, KZ number(1,0), FAELLIG timestamp, LAUFZEITBEGINN timestamp, ART number(1,0), ZKBPASSIV char(1 char), primary key (KONTONUMMER))
19:01:37,625 ERROR [SchemaUpdate] ORA-00955: name is already used by an existing object


Columns of the Oracle View
Code:
View VTERMINGELDER2
==========================
KONTONUMMER - NUMBER (10)
KUNDENNUMMER - NUMBER (10)
ART - NUMBER (1)
LAUFZEITBEGINN - DATE
ANLAGEVOLUMEN - NUMBER (24,2)
SOLLZINS - NUMBER (5,3)
ZINSSATZ - NUMBER (5,3)
FAELLIG - DATE
KZ - NUMBER (1)
ANLAGEFRIST - NUMBER (3)
ZKBPASSIV - NUMBER (24,2)


Java Entity Class
Code:
package de.lbb.forcev2.pricing.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity(name = "VTERMINGELDER2")
public class TimeDeposit {

    private Integer accountNumber;
    private Integer customerNumber;
    private Boolean type;
    private Date startDate;
    private BigDecimal investmentVolumne;
    private BigDecimal interest;
    private BigDecimal interestRate;
    private Date maturityDate;
    private Boolean kz;
    private BigInteger investmentPeriod;
    private BigDecimal zkbPassive;

    /** @return the accountNumber */
    @Column(name = "KONTONUMMER")
    @Id
    public Integer getAccountNumber() {
        return accountNumber;
    }

    /** @param accountNumber the accountNumber to set */
    public void setAccountNumber(Integer accountNumber) {
        this.accountNumber = accountNumber;
    }

    /** @return the customerNumber */
    @Column(name = "KUNDENNUMMER")
    public Integer getCustomerNumber() {
        return customerNumber;
    }

    /** @param customerNumber the customerNumber to set */
    public void setCustomerNumber(Integer customerNumber) {
        this.customerNumber = customerNumber;
    }

    /** @return the type */
    @Column(name = "ART")
    public Boolean getType() {
        return type;
    }

    /** @param type the type to set */
    public void setType(Boolean type) {
        this.type = type;
    }

    /** @return the startDate */
    @Temporal(TemporalType.DATE)
    @Column(name = "LAUFZEITBEGINN")
    public Date getStartDate() {
        return startDate;
    }

    /** @param startDate the startDate to set */
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    /** @return the investmentVolumne */
    @Column(name = "ANLAGEVOLUMEN", precision = 24, scale = 2)
    public BigDecimal getInvestmentVolumne() {
        return investmentVolumne;
    }

    /** @param investmentVolumne the investmentVolumne to set */
    public void setInvestmentVolumne(BigDecimal investmentVolumne) {
        this.investmentVolumne = investmentVolumne;
    }

    /** @return the interest */
    @Column(name = "SOLLZINS", precision = 5, scale = 3)
    public BigDecimal getInterest() {
        return interest;
    }

    /** @param interest the interest to set */
    public void setInterest(BigDecimal interest) {
        this.interest = interest;
    }

    /** @return the interestRate */
    @Column(name = "ZINSSATZ", precision = 5, scale = 3)
    public BigDecimal getInterestRate() {
        return interestRate;
    }

    /** @param interestRate the interestRate to set */
    public void setInterestRate(BigDecimal interestRate) {
        this.interestRate = interestRate;
    }

    /** @return the maturityDate */
    @Temporal(TemporalType.DATE)
    @Column(name = "FAELLIG")
    public Date getMaturityDate() {
        return maturityDate;
    }

    /** @param maturityDate the maturityDate to set */
    public void setMaturityDate(Date maturityDate) {
        this.maturityDate = maturityDate;
    }

    /** @return the kz */
    @Column(name = "KZ")
    public Boolean getKz() {
        return kz;
    }

    /** @param kz the kz to set */
    public void setKz(Boolean kz) {
        this.kz = kz;
    }

    /** @return the investmentPeriod */
    @Column(name = "ANLAGEFRIST", precision = 3)
    public BigInteger getInvestmentPeriod() {
        return investmentPeriod;
    }

    /** @param investmentPeriod the investmentPeriod to set */
    public void setInvestmentPeriod(BigInteger investmentPeriod) {
        this.investmentPeriod = investmentPeriod;
    }

    /** @return the zkbPassive */
    @Column(name = "ZKBPASSIV", precision = 24, scale = 2)
    public BigDecimal getZkbPassive() {
        return zkbPassive;
    }

    /** @param zkbPassive the zkbPassive to set */
    public void setZkbPassive(BigDecimal zkbPassive) {
        this.zkbPassive = zkbPassive;
    }

}


Last edited by altes-kind on Fri Feb 29, 2008 9:08 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 5:17 am 
Newbie

Joined: Wed Feb 27, 2008 1:55 pm
Posts: 3
Location: Germany
Sorry... I'm still not able to map this View in Oracle with Hibernate. Any ideas?

Thanks a lot!

altes-kind


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 7:30 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Hi,

I'm also interested to know how to map an Entity to a database view.

What I can see from your code is some misunderstanding of the "name" annotation for an entity. I think you want to map here the name of your view, but what you are doing is naming the Entity. The JPA spec says:
The name annotation element defaults to the unqualified name of the entity class. This name is used to refer to the entity in queries.

Anyway, I wonder if it is possible at all to map an Entity to a View? I suppose, this will not work. Or is there anybody out there who successfully did this?

Carlo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.