Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hibernate: 1:n Mapping

Empfohlene Antworten

Hallo Leute,

versuche mich gerade an einem Mapping mit Hibernate. Leider bekomme ich die 1:n Beziehung nicht gebacken. Ich möchte meine Objekte mit dem Inhalt folgender Tabellen füllen:


-------------------            -------------------

|   | TBL_Firma   |            |   | TBL_Filiale |

-------------------            -------------------

|PK| ID           | 1--------* |PK| ID           |

|   | name        |            |FK|  firmaId     |

                  |            |  | name         |

-------------------            |  | haendlerNr   |

                               -------------------

Alle Klassen Erben vom AAObject damit jede id und name bekommt:
package typen;


public class AAObject {


	protected String name;

	protected int id=0;


	public AAObject(){


	}


	/**

	 * @return

	 */

	public String getName() {

		if (name==null){

			name=null;

		}

		return name;

	}


	/**

	 * @param string

	 */

	public void setName(String string) {

		name = string;

	}


	public String toString(){

		return name;

	}


	public void setId(int id) {

		this.id = id;

	}


	public int getId() {

		return id;

	}

}

Die Klasse Firma sieht so aus:
package firma;


import java.util.HashSet;

import java.util.Set;


import typen.AAObject;


public class Firma extends AAObject{


	private Set filialen = new HashSet();


	public Set getFilialen() {

		return filialen;

	}


	public void setFilialen(Set filialen) {

		this.filialen = filialen;

	}

}

Die Klasse Filiale sieht so aus:
package corp.bmw.emeadecentral.nl_m.auszahlungsanweisung.filiale;


import corp.bmw.emeadecentral.nl_m.auszahlungsanweisung.typen.AAFachbereich;

import corp.bmw.emeadecentral.nl_m.auszahlungsanweisung.typen.AAObject;


public class Filiale extends AAObject {


        private String haendlerNr;


	/**

	 * @return

	 */

	public String getHaendlerNr() {

		return haendlerNr;

	}


	/**

	 * @param string

	 */

	public void setHaendlerNr(String string) {

		haendlerNr = string;

	}


}

Leider komm ich nicht drauf, wie meine Firma.hbm.xml und Filiale.hbm.xml aussehen müssen.

Servus,

kennst Du diese Seite: Chapter 5. Basic O/R Mapping ?

Hier ist alles beschrieben. Gleich im ersten Beispiel kommt sogar ein set mit vor.

Bei Detailfragen meldest Du Dich einfach noch mal.

Peter

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.