JPA - ManyToMany Problem - keine Unique Mehrfachzuweisungen

andyx1975

Aktives Mitglied
Hallo,

ich verwende EclipseLink / JPA für den Datenbank Zugriff und habe mir 2 Entity Klassen gebaut. Den Emails können Uploads zugewiesen werden. Hierzu gibt es die folgende Liste:

Java:
@ManyToMany ( fetch = FetchType.EAGER )
    @JoinTable( name = "assignments_emails_uploads", joinColumns = @JoinColumn( name = "email_id", referencedColumnName = "email_id" ), inverseJoinColumns = @JoinColumn( name = "upload_id", referencedColumnName = "upload_id" ) )
    private List<DUpload> uploads;


JPA legt zurzeit die Tabelle in PostgreSQL wie folgt an:
SQL:
CREATE TABLE assignments_emails_uploads
(
  email_id serial NOT NULL,
  upload_id serial NOT NULL,
  CONSTRAINT assignments_emails_uploads_pkey PRIMARY KEY (email_id, upload_id),
  CONSTRAINT fk_assignments_emails_uploads_email_id FOREIGN KEY (email_id)
      REFERENCES email_sended (email_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_assignments_emails_uploads_upload_id FOREIGN KEY (upload_id)
      REFERENCES email_uploads (upload_id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (OIDS=TRUE);
ALTER TABLE assignments_emails_uploads OWNER TO postgres;


Mein Problem ist jetzt dass ich einen Upload nicht mehrmals der gleichen Email zuweisen kann. Hierbei bekomme ich eine Fehlermeldung. Kann ich das irgendwie abstellen?

Java:
[EL Warning]: 2012-01-12 13:28:41.059--UnitOfWork(2068447)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.BatchUpdateException: Batch-Eintrag 0 INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES ('801', '601') wurde abgebrochen.  Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
Error Code: 0
Call: INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES (?, ?)
	bind => [2 parameters bound]
javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.BatchUpdateException: Batch-Eintrag 0 INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES ('801', '601') wurde abgebrochen.  Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
Error Code: 0
Call: INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES (?, ?)
	bind => [2 parameters bound]
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
	at com.uds.webadmin.server.CRestEmails.addAssignments(CRestEmails.java:178)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.BatchUpdateException: Batch-Eintrag 0 INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES ('801', '601') wurde abgebrochen.  Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
Error Code: 0
Call: INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES (?, ?)
	bind => [2 parameters bound]
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1494)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeJDK12BatchStatement(DatabaseAccessor.java:866)
	at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:144)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.writesCompleted(DatabaseAccessor.java:1707)
	at org.eclipse.persistence.internal.sessions.AbstractSession.writesCompleted(AbstractSession.java:3821)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.writesCompleted(UnitOfWorkImpl.java:5509)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.acquireWriteLocks(UnitOfWorkImpl.java:1612)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitTransactionAfterWriteChanges(UnitOfWorkImpl.java:1580)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:273)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1135)
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
	... 39 more
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 INSERT INTO assignments_emails_uploads (upload_id, email_id) VALUES ('801', '601') wurde abgebrochen.  Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
	at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
	at org.postgresql.core.v3.QueryExecutorImpl$1.handleError(QueryExecutorImpl.java:459)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
	at org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.executeBatch(DatabasePlatform.java:2042)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeJDK12BatchStatement(DatabaseAccessor.java:860)
	... 48 more
12.01.2012 13:28:41 com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SCHWERWIEGEND: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.UnsatisfiedLinkError: com.smartgwt.client.util.SC.say(Ljava/lang/String;)V
	at com.smartgwt.client.util.SC.say(Native Method)
	at com.uds.webadmin.server.CRestEmails.addAssignments(CRestEmails.java:186)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
	at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
	at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)




Email Entity Klasse:
Java:
package com.uds.webadmin.data;

import static javax.persistence.TemporalType.TIMESTAMP;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

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.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Entity implementation class for Entity: DEmail
 */
@Entity
@XmlRootElement
@Table( name = "email_sended" )
@NamedQuery( name = "findEmails", query = "SELECT e FROM DEmail e ORDER BY e.creation_date DESC" )
public class DEmail
    implements Serializable
{

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO )
    @SequenceGenerator( name = "email_sended_id_seq", sequenceName = "email_sended_id_seq", allocationSize = 1 )
    @Column( columnDefinition = "SERIAL" )
    private long email_id;

    @Column( columnDefinition = "TEXT" )
    private String to_recipients;

    @Column( columnDefinition = "TEXT" )
    private String cc_recipients;

    @Column( columnDefinition = "TEXT" )
    private String bcc_recipients;

    @Column
    private String headline;

    @Column( columnDefinition = "TEXT" )
    private String email_text;

    @Column
    private int email_type;

    @Column
    private Boolean self_copy;

    @Column
    private String creator;

    @Column
    @Temporal( TIMESTAMP )
    private Date creation_date;

    @ManyToMany ( fetch = FetchType.EAGER )
    @JoinTable( name = "assignments_emails_uploads", joinColumns = @JoinColumn( name = "email_id", referencedColumnName = "email_id" ), inverseJoinColumns = @JoinColumn( name = "upload_id", referencedColumnName = "upload_id" ) )
    private List<DUpload> uploads;

    private static final long serialVersionUID = 1L;

    public DEmail()
    {
        super();
    }

    public long getEmail_id()
    {
        return email_id;
    }

    public void setEmail_id( long email_id )
    {
        this.email_id = email_id;
    }

    public String getTo_recipients()
    {
        return to_recipients;
    }

    public void setTo_recipients( String to_recipients )
    {
        if ( to_recipients.trim().equals( "null" ) )
        {
            to_recipients = null;
        }

        this.to_recipients = to_recipients;
    }

    public String getCc_recipients()
    {
        return cc_recipients;
    }

    public void setCc_recipients( String cc_recipients )
    {
        if ( cc_recipients.trim().equals( "null" ) )
        {
            cc_recipients = null;
        }

        this.cc_recipients = cc_recipients;

    }

    public String getBcc_recipients()
    {
        return bcc_recipients;
    }

    public void setBcc_recipients( String bcc_recipients )
    {
        if ( bcc_recipients.trim().equals( "null" ) )
        {
            bcc_recipients = null;
        }
        this.bcc_recipients = bcc_recipients;
    }

    public String getHeadline()
    {
        return headline;
    }

    public void setHeadline( String headline )
    {
        if ( headline.trim().equals( "null" ) )
        {
            headline = null;
        }
        this.headline = headline;
    }

    public String getEmail_text()
    {
        return email_text;
    }

    public void setEmail_text( String email_text )
    {
        if ( email_text.trim().equals( "null" ) )
        {
            email_text = null;
        }
        this.email_text = email_text;
    }

    public int getEmail_type()
    {
        return email_type;
    }

    public void setEmail_type( int email_type )
    {
        this.email_type = email_type;
    }

    public Boolean getSelf_copy()
    {
        return self_copy;
    }

    public void setSelf_copy( Boolean self_copy )
    {
        this.self_copy = self_copy;
    }

    public String getCreator()
    {
        return creator;
    }

    public void setCreator( String creator )
    {
        this.creator = creator;
    }

    public Date getCreation_date()
    {
        return creation_date;
    }

    public void setCreation_date( Date creation_date )
    {
        this.creation_date = creation_date;
    }

    public List<DUpload> getUploads()
    {
        return uploads;
    }

    public void setUploads( List<DUpload> uploads )
    {
        this.uploads = uploads;
    }

    public static long getSerialversionuid()
    {
        return serialVersionUID;
    }

    
}


Upload Entity Klasse:
Java:
package com.uds.webadmin.data;

import static javax.persistence.TemporalType.TIMESTAMP;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

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.ManyToMany;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * Entity implementation class for Entity: email_uploads
 */
@Entity
@Table( name = "email_uploads" )
@XmlRootElement
@NamedQuery( name = "findUploads", query = "SELECT e FROM DUpload e ORDER BY e.creation_date DESC" )
public class DUpload
    implements Serializable
{

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO )
    @SequenceGenerator( name = "email_uploads_id_seq", sequenceName = "email_uploads_id_seq", allocationSize = 1 )
    @Column( columnDefinition = "SERIAL" )
    private long upload_id;

    @Column
    private String upload_name;

    @Column
    private int upload_type;

    @Column
    private String creator;

    @Column
    private String upload_link;

    @Column
    private Boolean status;

    @Column
    @Temporal( TIMESTAMP )
    private Date creation_date;

    @Column
    private String editor;

    @Column
    @Temporal( TIMESTAMP )
    private Date edit_date;

    @ManyToMany( mappedBy = "uploads", fetch = FetchType.EAGER )
    private List<DEmail> emails;

    private static final long serialVersionUID = 1L;

    public DUpload()
    {

    }

    public DUpload( long upload_id, String upload_name, int upload_type, String creator, String upload_link,
                     Boolean status, Date creation_date, String editor, Date edit_date )
    {
        this.upload_id = upload_id;
        this.upload_name = upload_name;
        this.upload_type = upload_type;
        this.creator = creator;
        this.upload_link = upload_link;
        this.status = status;
        this.creation_date = creation_date;
        this.editor = editor;
        this.edit_date = edit_date;
    }

    public long getUpload_id()
    {
        return upload_id;
    }

    public void setUpload_id( long upload_id )
    {
        this.upload_id = upload_id;
    }

    public String getUpload_name()
    {
        return upload_name;
    }

    public void setUpload_name( String upload_name )
    {
        this.upload_name = upload_name;
    }

    public int getUpload_type()
    {
        return upload_type;
    }

    public void setUpload_type( int upload_type )
    {
        this.upload_type = upload_type;
    }

    public String getCreator()
    {
        return creator;
    }

    public void setCreator( String creator )
    {
        this.creator = creator;
    }

    public String getUpload_link()
    {
        return upload_link;
    }

    public void setUpload_link( String upload_link )
    {
        this.upload_link = upload_link;
    }

    public Boolean getStatus()
    {
        return status;
    }

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

    public Date getCreation_date()
    {
        return creation_date;
    }

    public void setCreation_date( Date creation_date )
    {
        this.creation_date = creation_date;
    }

    public String getEditor()
    {
        return editor;
    }

    public void setEditor( String editor )
    {
        this.editor = editor;
    }

    public Date getEdit_date()
    {
        return edit_date;
    }

    public void setEdit_date( Date edit_date )
    {
        this.edit_date = edit_date;
    }

    public static long getSerialversionuid()
    {
        return serialVersionUID;
    }

    @XmlTransient
    public List<DEmail> getEmails()
    {
        return emails;
    }

    public void setEmails( List<DEmail> emails )
    {
        this.emails = emails;
    }
    
}
 
Zuletzt bearbeitet:

DerFeivel

Bekanntes Mitglied
SQL:
CONSTRAINT assignments_emails_uploads_pkey PRIMARY KEY (email_id, upload_id)

Die Kombination aus Email_Id und Upload soll Primary Key sein, also eindeutig und identifizierend?



Und du willst jetzt einer Email einen Anhang 2 Mal zuordnen?

Hast dann also zweimal das Tupel (e1,u1) ?


Und überhaupt:

Warum?
 

andyx1975

Aktives Mitglied
Danke für dein Feedbacl.... Also in der Praxis hast du recht. An dieser Stelle macht es keinen Sinn einen Anhang zweimal hinzu zu fügen. Ich möchte es nur generell rausfinden, da ich es an anderen Stellen noch brauchen werde. Aber du hast meine Frage richtig verstanden. Die IDs sind primary keys... dein zitierter Contraint wird von JPA automatisch angelegt, ohne dass ich das so festlege.
 
N

nillehammer

Gast
DerFeivel hat gesagt.:
Und du willst jetzt einer Email einen Anhang 2 Mal zuordnen?

Hast dann also zweimal das Tupel (e1,u1) ?


Und überhaupt:

Warum?
Habe ich mich zunächst auch gefragt, warum andyx1975 das will. Aber in einem normalen Emailprogramm ist es ja auch möglich, zwei Mal dieselbe Datei anzuhängen...

Und zur eigentlichen Frage:
Der Schemagenerator verhält sich eben so, dass er bei Beziehungstabellen den PrimaryKey über die JoinColumns legt. Das macht ja normalerweise auch sehr viel Sinn. Mir ist nicht bekannt, wie man den customizen kann. Insofern glaube ich, Du musst das mit einer eigenen Entity modellieren, die eine Referenz auf Email, eine auf Upload und ein int für die Anzahl enthält (Ich glaube in UML nennt man sowas ternäre Assoziation).
 
Zuletzt bearbeitet von einem Moderator:
Ähnliche Java Themen
  Titel Forum Antworten Datum
B Problem mit @ManyToMany und CascadeType.ALL Data Tier 3
J Hibernate @ManyToMany: Keine Werte in der JoinTable Data Tier 0
A ManyToMany löscht zugewiesene Dateien Data Tier 1
M JPA ManyToMany mit zusätzlicher Spalte Data Tier 0
A @ManyToMany - Kein Löschen bereits zugewiesener Entities Data Tier 6
A EclipseLink JPA - ManyToMany und Select Abfrage Data Tier 8
I EJB3 @ManyToMany Data Tier 4
GilbertGrape hibernate: manyToMany primaryKey in Verknüpfungstabelle? Data Tier 2
N Problem beim initialisieren des Caches Data Tier 0
S JPA Problem mit Cascading Data Tier 1
M Eclipse 4 RCP Hibernate Problem Data Tier 3
C JPA FetchType.LAZY, Relation @OneToMany und Problem mit dem update Data Tier 1
K Problem mit EJBs und Transaktionen Data Tier 0
G JPA: Entity Klasse @JoinColumns Problem Data Tier 2
M JPA Problem: java.sql.SQLSyntaxErrorException: Data Tier 7
H Hibernate Problem mit Lazy Loading bei @OneToMany Collections Data Tier 5
M MySql und JPA-Timestamp Problem Data Tier 8
J Hibernate Problem bei Master-Detail-Tabellen Data Tier 5
M Problem beim Laden von Objekten, die von anderen Applikationen in eine DB eingefügt wurden Data Tier 5
M Problem mit @Temporal Mapping und SQL Server Data Tier 3
P JPA - HashMap mit Many-to-Many Relation Problem Data Tier 4
Blackskyliner [JPA][Anfänger] Problem mit Wertzuweisung aus Verbundtabelle Data Tier 2
B Problem mit org.hibernate.LazyInitializationException Data Tier 11
B DatenquellenUpdater extends Thread - Problem mit PermGenSpace Data Tier 5
S Problem beim Insert mit Hibernate Data Tier 9
Y [openJPA] Problem mit Transaktion? Data Tier 2
A @SecondaryTable Problem Data Tier 9
N Problem beim session.flush(); Data Tier 17
Y Postgres und JPA - Primärschlüssel Problem Data Tier 3
P SQL PRoblem Hibernate? Data Tier 8
Y EJB Problem mit Transaktionen Data Tier 7
M Transaction / Session Problem Data Tier 4
G JPA 2.0 Query Problem Data Tier 3
P CORBA Problem bei EJB 3.0 Anwendung in Glassfish v3 Data Tier 7
F Problem mit Hibernate Schema Update Data Tier 2
S Lazy loading Problem Data Tier 2
M Insert-Problem mit JPA/Hibernate Data Tier 4
megachucky JPA - Problem mit Persistence Unit / Context Data Tier 1
H Hibernate Problem Data Tier 4
D Performance Problem mit Prepared Statement Data Tier 6
T Problem mit openJPA Data Tier 7
P Problem mit Data Tier 9
GilbertGrape Cascade Problem (Hibernate) Data Tier 3
C JPA Problem mit attributeOverride und mehrspaltigem PK Data Tier 2
B select "neu" statement Problem (jpql) Data Tier 8
boxi Hibernate Lazy Loading Problem Data Tier 2
M Problem mit Hibernate und SLF4J - NoSuchMethodException Data Tier 3
G Connection Problem - WAS 6.1, Hibernate, OS Authentication Data Tier 1
K Hibernate update-Problem Data Tier 36
J hibernate problem Data Tier 14
N Hibernate - Problem mit Update/Insert Data Tier 4
B Problem mit @PersistenceContext Data Tier 4
G Problem with mapped of the tables at one to one relationship Data Tier 8
R JPA getSingleResult(...) wirft keine erwartete NonUnique-Exception Data Tier 0
G Hibernate SQL in Hibernate: Keine Parameter mit Index? Data Tier 2
S JPA Validation - keine Annotations gefunden Data Tier 2
G keine Tuples doppelt Data Tier 3
S JPA Toplink Generate Tables from Entities erzeugt keine Outputfile Data Tier 9
B hibernate und list - Keine Ordnung möglich Data Tier 8

Ähnliche Java Themen


Oben