Git Product home page Git Product logo

m6_exercici2_uf2's Introduction

Exercici2_UF2

Ens han passat un projecte amb el codi que veieu en aquest repositori. D'altra banda, sols hem creat l'esquema de base de dades (com podeu veure al hibernate.conf.xml, anomenat "clients"), però no hem creat cap taula ni afegit cap camp. Deixarem que hibernate ho faci per nosaltres.

Així, quan anem a executar el projecte, ens dona un error.

Error en la inicialización. org.hibernate.MappingException: Repeated column in mapping for entity: Model.Cliente column: ciudad (should be mapped with insert="false" update="false") Exception in thread "main" java.lang.ExceptionInInitializerError at app.HibernateUtil.(HibernateUtil.java:26) at app.App.main(App.java:10) Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: Model.Cliente column: ciudad (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:1007) at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:1024) at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:1020) at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:1052) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:716) at org.hibernate.mapping.RootClass.validate(RootClass.java:283) at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:376) at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:298) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:415) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:746) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:765) at app.HibernateUtil.(HibernateUtil.java:22)

Es tracta que bé modificant la classe Cliente o bé cambiant alguna configuració hibernate es pugui persistir l'objecte client i per tant que no doni més error.
RESPOSTA:

Solucio


La solució és afegir l'anotació @AttributeOverrides a una de les classes Direccion y que a l'hora d'insertar dades a la taula canvï el nom al que ti li indicas.
L'error es dona,ja que al declarar dos cops la classe Direccion a Cliente te els mateixos atributs repetits i per aixo donar error.

@AttributeOverrides({
        @AttributeOverride(name = "direccion", column = @Column(name = "direccionE")),
        @AttributeOverride(name = "ciudad", column = @Column(name = "ciudadE")),
        @AttributeOverride(name = "provincia", column = @Column(name = "provinciaE")),
        @AttributeOverride(name = "codigoPostal", column = @Column(name = "codigopostalE")) })

m6_exercici2_uf2's People

Contributors

p2021inf1 avatar acunidev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.