Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / Repeated column in mapping for entity / 3 сообщений из 3, страница 1 из 1
16.04.2017, 18:42
    #39439354
Hett
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Repeated column in mapping for entity
Код: plaintext
1.
2.
3.
[2017-04-16 10:41:22,038] Artifact mezoline:war: java.lang.Exception: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"mezoline-1.0-SNAPSHOT.war#mysql\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"mezoline-1.0-SNAPSHOT.war#mysql\": javax.persistence.PersistenceException: [PersistenceUnit: mysql] Unable to build Hibernate SessionFactory
    Caused by: javax.persistence.PersistenceException: [PersistenceUnit: mysql] Unable to build Hibernate SessionFactory
    Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.mezoline.domain.Product column: manufacturer_id (should be mapped with insert=\"false\" update=\"false\")"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.persistenceunit.\"mezoline-1.0-SNAPSHOT.war#mysql\""],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}

В каком месте он Repeated ?

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
package com.mezoline.domain;

import com.mezoline.domain.interfaces.Identified;


import javax.faces.bean.ManagedBean;
import javax.persistence.*;
import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.util.*;

/**
 * Created by Hett on 06.04.2017.
 * Store products data
 */

@Entity
@ManagedBean
@Transactional
public class Product implements Identified {

    @Id
    @GeneratedValue
    private Integer id;

    @Temporal(TemporalType.DATE)
    private Date created_at;

    @Temporal(TemporalType.DATE)
    private Date updated_at;

    private Boolean visible;

    private String name;

    private String description;

    private BigDecimal price;

    private Integer category_id;

    private Integer manufacturer_id;

    @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
    @JoinTable(
            name = "product_category",
            joinColumns = @JoinColumn(name = "product_id", referencedColumnName = "id"),
            inverseJoinColumns = @JoinColumn(name = "category_id", referencedColumnName = "id")

    )
    private Collection<Category> categories = new LinkedHashSet<>();

    @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
    @JoinColumn(name = "manufacturer_id", referencedColumnName = "id")
    private Manufacturer manufacturer;

    public void addCategory(Category category) {
        ProductCategory productCategory = new ProductCategory();
        productCategory.getId().setCategory_id(category.getId());
        productCategory.getId().setProduct_id(getId());
        productCategory.setProduct(this);
        productCategory.setCategory(category);
        categories.add(category);
        category.getProducts().add(this);
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getCategory_id() {
        return category_id;
    }

    public void setCategory(Category category) {
        category_id = category.getId();
        categories.add(category);
    }

    public Collection<Category> getCategories() {
        return categories;
    }

    public void setCategories(Collection<Category> categories) {
        this.categories = categories;
    }

    public Boolean getVisible() {
        return visible;
    }

    public void setVisible(Boolean visible) {
        this.visible = visible;
    }

    public Integer getManufacturer_id() {
        return manufacturer_id;
    }

    public void setManufacturer_id(Integer manufacturer_id) {
        this.manufacturer_id = manufacturer_id;
    }

    public void setManufacturer(Manufacturer manufacturer) {
        this.manufacturer = manufacturer;
    }

    public Manufacturer getManufacturer()
    {
        return manufacturer;
    }
}



Во всем проекте он даже больше нигде не упоминается.
...
Рейтинг: 0 / 0
16.04.2017, 18:47
    #39439356
Hett
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Repeated column in mapping for entity
Всё, дошло. Пока на форуме не напишешь, почему-то мысль не приходит.
...
Рейтинг: 0 / 0
16.04.2017, 19:32
    #39439361
Hett
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Repeated column in mapping for entity
А вообще не тафтология ли это?
Как понимаю он каким-то чудестным образом должен сам взаимные связи отслеживать и менять?

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
    public void addCategory(Category category) {
        ProductCategory productCategory = new ProductCategory();
        productCategory.getId().setCategory_id(category.getId());
        productCategory.getId().setProduct_id(getId());
        productCategory.setProduct(this);
        productCategory.setCategory(category);
        categories.add(category);
        category.getProducts().add(this);
    }
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / Repeated column in mapping for entity / 3 сообщений из 3, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]