"Illegal attempt to map non-collection as a @OneToMany, @ManyToMany or @CollectionOfElements"


mh123hack:

good morning #1,

I have the error problem it gives me:

Cannot create SessionFactory object.org.hibernate.AnnotationException: Illegal attempt to map non-collection as @OneToMany, @ManyToMany or @CollectionOfElements: nl.scalda.pasimo.model.employeemanagement.EducationTeam.coachGroups

Do you know why?

@OneToMany(cascade=CascadeType.ALL, targetEntity=CoachGroup.class)
@JoinColumn(name="id")
private TreeSet<CoachGroup> coachGroups = new TreeSet<>();
private SessionFactory factory;

private void initialiseFactory() {
    try {
        factory = new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) {
        System.err.println("Failed to create sessionFactory object." + ex);
        throw new ExceptionInInitializerError(ex);
    }
}
cнŝdk :

The only exception is straightforward: an illegal attempt to map a non-collection as a @OneToMany, @ManyToMany or @CollectionOfElements , so the reason is obvious here, if we take a look at the collection mapping documentation in Hibernate , it clearly states:

As a requirement persistent collection-valued fields must be declared as an interface type (see Example 7.2, "Using @OneToMany and @JoinColumn Collection Mappings"). The actual interface may be java.util.Set, java.util.Collection, java.util.List, java.util.Map, java.util.SortedSet, java.util.SortedMap...

And what you use TreeSet is an implementation class and interface. So, your actual mapping won't work together , you should use instead :Set<E>SortedSet<E>TreeSetSet<CoachGroup>TreeSet<CoachGroup>

private Set<CoachGroup> coachGroups = new HashSet<CoachGroup>();

Related


Automatic renewal of Let's Encrypt certificates

Automatic renewal of Let's Encrypt certificates Let's Encrypt free SSL certificate is very convenient to use, but each application is only valid for three months, and you need to re-apply before each expiration, but re-application is not troublesome, just need

Codeforces Round #492 (Div. 2) C. Tesla

Link http://codeforces.com/contest/996/problem/C answer My English is not good, I misunderstood the meaning of the question at first, so I wrote 3K _ 3 K The code results in non-stop WA W A , I later learned that a kind of garage can only allow the correspondi

JS block scope

Block scope means that variables and functions belong not only to the scope in which they are located, but also to a block of code (usually inside {..}) for(var i=0;i<10;i++){ var j = 12; } console.log(i,j)//10 12 When a variable is declared with var, no matte

X-Frame-Options response header configuration for web security

During project detection, there is a missing "X-Frame-Options" response header in the security report, indicating that cross-frame scripting attacks may occur, as follows: After inquiries, it was found that: X-Frame-Options: There are three values:   (1) DENY:

X-Frame-Options response header configuration for web security

During project detection, there is a missing "X-Frame-Options" response header in the security report, indicating that cross-frame scripting attacks may occur, as follows: After inquiries, it was found that: X-Frame-Options: There are three values:   (1) DENY:

The personal experience of an autodidact

I am an autodidact More than half a year ago, I started the front-end road. At that time, I only wanted to learn one technology, so I started a blind learning career. At the beginning, I searched what the front-end basics are mainly to learn, html , css , js ,

java-1006 Change the format to output integers (15)

1006 Change format to output integer (15) (15 points) Let's use the letter B for "hundred", the letter S for "ten", and "12...n" for the ones digit n (<10), and change the format to output any positive integer up to 3 digits. For example, 234 should be output

linux open port

Method of opening port: Method 1: Command line method 1. Open port command: /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT 2. Save: /etc/rc.d/init.d/iptables save 3. Restart the service: /etc/init.d/iptables restart 4. Check whether the port is open: /s

springMVC global exception

How to use HandlerExceptionResolver for global exception handling in Spring Configure log4jjar package Implement the HandlerExceptionResolver interface package cn.e3mall.search.exception; import javax.servlet.http.HttpServletRequest; import javax.servlet.http

Improvement of Qt third-party circular progress bar

To implement a circular progress bar function, find a well-known third-party package class on the Internet: QRoundProgressBar, address: sourceforge The QRoundProgressBar function is well packaged, providing 3 modes, linear, circular, and pie. During use, it is

Improvement of Qt third-party circular progress bar

To implement a circular progress bar function, find a well-known third-party package class on the Internet: QRoundProgressBar, address: sourceforge The QRoundProgressBar function is well packaged, providing 3 modes, linear, circular, and pie. During use, it is

Pandas-----Five Small Exercises

Data download link, click here first question drawing The second problem is grouped The third question types of conversions Fourth Inscription Frequency Processing The fifth question parameter statistics

Data analysis using python -- numpy 2

1. Access text files np.loadtxt() Convert text files to arrays np.savetxt() Convert arrays to text files 2. Linear algebra function 3. Random function in numpy

springBoot adds logs of sql statements

logging: level: com.zwl.dao: trace # Change to the package path where your mapper file is located The reason for this problem is: When the company's project was just started, there was no function of printing sql statements, so I thought of a way to add

Daily sql optimization commonly used shortcut scripts--by lixora

---- Get the execution plan of the last execution of sql select * from table(dbms_xplan.display('PLAN_TABLE',NULL,'ALLSTATS')); set linesize 230 pagesize 9999 select * from table(dbms_xplan.display_cursor(null,null,'ADVANCED note last')); /*+ gather_plan_stati

How to trigger a stage layout update in JavaFX

Eugene Covaci: I have a very simple JavaFX application that displays a form backed by a grid. In this form I have a checkbox. When the user checks this checkbox, I want to dynamically add another row to the grid. From my controller: checkbox.selectedProperty()

Anaconda vs Julia Autocorrelation

Ross Mariano: I am trying to use Julia to do autocorrelation and compare results in Python. Why do they give different results? Julia code using StatsBase t = range(0, stop=10, length=10) test_data = sin.(exp.(t.^2)) acf = StatsBase.autocor(test_data) Give

method to call a parallel list?

Charles arrives at Neue: I have to iterate over the list of each object and call the method, but in parallel. After the loop, there are other declarations, which have to wait for parallel method calls. How can I do this in JAVA? public void a(List<Object> list

PHP MySQL的覆瓦状排列的SELECT语句返回null

胡阿里·Zegai: 我试图执行查询,但结果却是零,我执行在phpMyAdmin相同的查询并返回结果。 问题是,当查询包含SELECT内的另一个SELECT语句(覆瓦状),所以当查询只包含一个SELECT语句,它工作正常,并返回结果。下面是代码: db_config.php <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "university_db"; // Create connection

Patched Java 9 Module Test Code Working and Thinking

itching: How can I add my tests to my production code during a pilot run so that both are the same Java 9 module and can access each other using reflection? So far I have tried: Removed Java Modularity 9 (actually module-info.java) → it worked perfectly, but n

Memory for invalid character "\"

Innewit : I'm new to ASM/shellcode and I'm having trouble compiling e.g. shellcode including templates in ParrotOS. I looked through the following topics, but it doesn't solve my problem: Assembly Error: Invalid character '$' in memory Invalid character in mem

linux shell su -c 'sed' command

solid color: $ sudo su - root -c 'sed -i '$a\PermitRootLogin yes' etc/ssh/sshd_config' After running the command, it always shows sed: -e expression #1, char 2: extra characters after command and $ sudo su - root -c "sed -i '$a\PermitRootLogin yes' etc/ssh/s

Create separate MD5 files recursively for each file

Toverofapover256: I've always wanted to keep an eye on my file storage and keep an eye out for damage over time when files get damaged. For this, I'm trying to write a bash/shell script for Linux that recurses through directories and creates an MD5 hash and fi

HTTP server from TCP socket (Go)

AjMyyra : I'm trying to create a Go TCP socket, bind it to a VRF interface , and set up an HTTP server on that specific interface. The VRF binding works correctly, but upon starting the HTTP server returns an error stating "Accept TCP 127.0.0.1:80: Accept: Inv