-->
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.  [ 6 posts ] 
Author Message
 Post subject: Anyone can helps me?
PostPosted: Sat Nov 26, 2016 1:59 pm 
Hello i cannot find my mistake in here.
Code:

package com.example;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "events")
public class events implements Serializable {
   private static final long serialVersionUID = 1L;

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   private int eventid;
   @Column(name = "eventdate")
   private Date eventdate;
   @Column(name = "eventplace")
   private String eventplace;
   @Column(name = "eventstatus")
   private boolean status;
   @ManyToMany(mappedBy = "eventSet")
   private Set<user> userliste;

   private sportarten sportart;

   public events() {
   }

   public events(String name) {
      setEventplace(name);
   }

   public events(events search, HashSet<user> hashSet) {
      setUser(hashSet);
   }

   public Set<user> getUser() {
      return userliste;
   }

   public void setUser(Set<user> user) {
      this.userliste = user;
   }

   public void setEventid(int eventid) {
      this.eventid = eventid;
   }

   @ManyToOne  //(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
   @JoinColumn(name="sportart")
   public sportarten getsportart() {
      return sportart;
   }

   public void setsportart(sportarten eventtyp) {
      this.sportart = eventtyp;
   }

   public Set<user> getUserliste() {
      return userliste;
   }

   public void setUserliste(Set<user> userliste) {
      this.userliste = userliste;
   }

   public int getEventid() {
      return eventid;
   }

   public Date getEventdate() {
      return eventdate;
   }

   public void setEventdate(Date eventdate) {
      this.eventdate = eventdate;
   }

   public String getEventplace() {
      return eventplace;
   }

   public void setEventplace(String eventplace) {
      this.eventplace = eventplace;
   }

   public boolean isStatus() {
      return status;
   }

   public void setStatus(boolean status) {
      this.status = status;
   }

}





Code:
package com.example;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "sportarten")
public class sportarten implements Serializable {

   @Id
   @Column(name = "sportart")
   private String Sportart;

   @Column(name = "maxspieler")
   private int maxSpieler;

   @ElementCollection(targetClass = events.class)
   private Set<events> eventinkat;

   public sportarten(String sportart, int maxSpieler, HashSet<events> hashSet) {
      super();
      Sportart = sportart;
      this.maxSpieler = maxSpieler;
      this.eventinkat = hashSet;
   }

   public String getSportart() {
      return Sportart;
   }

   public void setSportart(String sportart) {
      Sportart = sportart;
   }

   public int getMaxSpieler() {
      return maxSpieler;
   }

   public void setMaxSpieler(int maxSpieler) {
      this.maxSpieler = maxSpieler;
   }

   @OneToMany //(targetEntity = events.class, mappedBy = "sportart", fetch = FetchType.EAGER)
   public Set<events> getEventinkat() {
      return eventinkat;
   }

   public void setEventinkat(Set<events> eventListe) {
      this.eventinkat = eventListe;
   }

   public sportarten() {

   }

}





Image




Where is the mistake?
The comments after ONETOMANY and MANYTOMANY makes no difference..


And i have now to create controllers MVC and work with them in a website.
Any tipps what would be the easiest way?Or do you know where to find a good example for it?


Top
  
 
 Post subject: Re: Anyone can helps me?
PostPosted: Sat Nov 26, 2016 2:03 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
It's not clear what's the problem.


Top
 Profile  
 
 Post subject: Re: Anyone can helps me?
PostPosted: Sat Nov 26, 2016 2:32 pm 
in the picture you can see that the table events always get some wrong elements.


Top
  
 
 Post subject: Re: Anyone can helps me?
PostPosted: Sat Nov 26, 2016 3:04 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
My best advice is to fully read the Hibernate User Guide, and this tutorial.

We also have a Getting Started Guide where you can find some examples.


Top
 Profile  
 
 Post subject: Re: Anyone can helps me?
PostPosted: Sun Nov 27, 2016 5:28 am 
will read them today.but i have still some questions .

do i have to map the entities or does spring does this automaticly?
And how can i only get the string of the class/table to the other and not the hole object.


Top
  
 
 Post subject: Re: Anyone can helps me?
PostPosted: Sun Nov 27, 2016 6:18 am 
okay..got it...changed the typ of sportart in events.class to a string and only catched the string in the getters


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.