From 80c928921e7c3cb0ae0ce31f1903e5d8ff15da08 Mon Sep 17 00:00:00 2001 From: Socrates Date: Fri, 29 May 2020 15:22:50 +0200 Subject: [PATCH] Adding more cross references --- properties/xava.properties | 2 +- .../yourcompany/babydatenbank/model/Article.java | 14 ++++++-------- .../yourcompany/babydatenbank/model/Brand.java | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/properties/xava.properties b/properties/xava.properties index 7fd0b46..ad2620d 100644 --- a/properties/xava.properties +++ b/properties/xava.properties @@ -45,7 +45,7 @@ smtpStartTLSEnable=false # This affects only if Java logging is used (usually in Tomcat and WebSphere). # It does not affect log4j configuration (usually in JBoss or if you use log4j in your app). # Default value is INFO -javaLoggingLevel=INFO +javaLoggingLevel=FINE # LOGGING LEVEL FOR HIBERNATE ENGINE # Possibles values are: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL, OFF diff --git a/src/com/yourcompany/babydatenbank/model/Article.java b/src/com/yourcompany/babydatenbank/model/Article.java index e27e6fb..de3be5a 100644 --- a/src/com/yourcompany/babydatenbank/model/Article.java +++ b/src/com/yourcompany/babydatenbank/model/Article.java @@ -20,9 +20,7 @@ import java.time.*; ) public class Article { - @Id - @Hidden - @GeneratedValue(generator="system-uuid") // Universally Unique Identifier (1) + @Id @Hidden @GeneratedValue(generator="system-uuid") // Universally Unique Identifier (1) @GenericGenerator(name="system-uuid", strategy = "uuid") @Column(length=32) private String oid; @@ -34,27 +32,27 @@ public class Article { @Column(length=83886080) private byte[] photo; - @ManyToOne(fetch=FetchType.LAZY, optional=true) + @ManyToOne @NoModify @DescriptionsList private Size size; - @ManyToOne(fetch=FetchType.LAZY, optional=true) + @ManyToOne @NoModify @DescriptionsList private Pattern pattern; - @ManyToOne(fetch=FetchType.LAZY, optional=true) + @ManyToOne(optional=true, fetch = FetchType.EAGER) @NoModify @DescriptionsList private Category category; - @ManyToOne(fetch=FetchType.LAZY, optional=true) + @ManyToOne @NoModify @DescriptionsList private Brand brand; - @ManyToOne(fetch=FetchType.LAZY, optional=true) + @ManyToOne @NoCreate @NoModify @DescriptionsList(order="${number} ASC") diff --git a/src/com/yourcompany/babydatenbank/model/Brand.java b/src/com/yourcompany/babydatenbank/model/Brand.java index 833f54b..9e9e772 100644 --- a/src/com/yourcompany/babydatenbank/model/Brand.java +++ b/src/com/yourcompany/babydatenbank/model/Brand.java @@ -3,6 +3,7 @@ package com.yourcompany.babydatenbank.model; import javax.persistence.*; import org.hibernate.annotations.GenericGenerator; import org.openxava.annotations.*; +import java.util.*; @Entity public class Brand { @@ -16,6 +17,10 @@ public class Brand { @Column(length=20) private String description; + + @OneToMany(mappedBy="brand", fetch = FetchType.EAGER) + @ListProperties("name, category.description") + private Collection
articles; public String getOid() { return oid; @@ -32,5 +37,15 @@ public class Brand { public void setDescription(String description) { this.description = description; } + + public Collection
getArticles() { + return articles; + } + + public void setArticles(Collection
articles) { + this.articles = articles; + } + + }