Bug 389816 - Warn with single table inheritance with nonnull field
Summary: Warn with single table inheritance with nonnull field
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-18 10:05 EDT by Wouter Oet CLA
Modified: 2022-06-09 10:09 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Oet CLA 2012-09-18 10:05:11 EDT
EclipseLink should warn or even stop deployment when a single table inheritance strategy is used with a subclass having a nonnull field. Otherwise other entities is the object tree can't be persisted. This moves the failure from "runtime" to "deploytime". E.g.:

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type")
@DiscriminatorValue("A")
public class A {

	@Id
	@GeneratedValue
	public long id;
	public String name;
}

@Entity
@DiscriminatorValue("B")
public class B extends A {

	@Column(nullable = false)
	public String something;
}

@Singleton
@javax.ejb.Startup
public class Startup {

	@PersistenceContext
	private EntityManager em;

	@PostConstruct
	public void init() {
		A a = new A();
		a.name = "asdf";

		em.persist(a); // No go
	}
}
Comment 1 Eclipse Webmaster CLA 2022-06-09 10:09:05 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink