Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Strange column naming, when setting AttributeOverrides in entities
Strange column naming, when setting AttributeOverrides in entities [message #1869705] Thu, 22 August 2024 07:36 Go to next message
Eclipse UserFriend
I have an abstract @MappedSuperclass like this:

public abstract class JpaAbstractEntity implements Entity, Created, CreatedBy, Updated, UpdatedBy, DeletedBy, UuidIdentifiable
{
	@Transient
	private static final long serialVersionUID = 36023547253970211L;

	@Transient
	protected static JpaAccount currentAccount;
	
	@Transient
	protected transient PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
	
	@Id
	@Column(columnDefinition = "CHAR(36)")
	@GeneratedValue(strategy = GenerationType.UUID, generator = "UUID_GEN")
	protected UUID id;
	
	@Version
	@Column(name = "version")
	protected int version;

	@Basic
	@Column(name = "created")
	@Temporal(TemporalType.TIMESTAMP)
	protected Calendar created;

	@ManyToOne(optional = true)
	@JoinColumn(referencedColumnName = "account_id")
	protected JpaAccount createdBy;

	@Basic
	@Column(name = "updated")
	@Temporal(TemporalType.TIMESTAMP)
	protected Calendar updated;

	@ManyToOne(optional = true)
	@JoinColumn(referencedColumnName = "account_id")
	protected JpaAccount updatedBy = null;


Any of my concrete entities save created, updated, deleted resp. createdBy, updatedBy, deletedBy values. Because I do not want create those fields in each concrete class, I use the given abstract superclass JpaAbstractEntity.

All concrete entities classes looks like this in the header (this is an example):

@Entity
@UuidGenerator(name="UUID_GEN")
@Table(name = "category")
@AttributeOverrides({
	@AttributeOverride(name="id", column=@Column(name="category_id")),
	@AttributeOverride(name="version", column=@Column(name="category_version")),
	@AttributeOverride(name="deleted", column=@Column(name="category_deleted")),
	@AttributeOverride(name="deletedBy", column=@Column(name="category_deleted_by")),
	@AttributeOverride(name="created", column=@Column(name="category_created")),
	@AttributeOverride(name="createdBy", column=@Column(name="category_created_by")),
	@AttributeOverride(name="updated", column=@Column(name="category_updated")),
	@AttributeOverride(name="updatedBy", column=@Column(name="category_updated_by")),
})
public class JpaCategory extends JpaAbstractEntity implements Category


I want, that the table columns have the names as shown in this example, so category_created_by and so on. But what the table column names look like is (only for the fields createdBy, updatedBy, deletedBy):

CREATEDBY_account_id
UPDATEDBY_account_id
DELETEDBY_account_id

instead of (for the example above):

category_created_by
category_updated_by
category_deleted_by

the other fields/column names are ok.

Has anybody an idea, why this strange naming occurres? Thank you!

If required I can give more code snippets.
Re: Strange column naming, when setting AttributeOverrides in entities [message #1873414 is a reply to message #1869705] Mon, 16 December 2024 08:30 Go to previous message
Eclipse UserFriend
Just looking at one, deletedBy - where is it mapped and where is it implemented?

For relationships, you need to use AssociationOverrides:

@AssociationOverrides({
  @AssociationOverride(name="deletedBy", joincolumns=@JoinColumn(name="category_deleted_by")),
  @AssociationOverride(name="createdBy", joincolumns=@JoinColumn(name="category_created_by")),
  @AssociationOverride(name="updatedBy", joincolumns=@JoinColumn(name="category_updated_by")),
})

[Updated on: Mon, 16 December 2024 08:41] by Moderator

Previous Topic:Access Errors for statically weaved classes in a consuming java module
Next Topic:Way to prevent eclipse link inserting nulls when using circular foreign keys
Goto Forum:
  


Current Time: Sat Aug 16 16:47:23 EDT 2025

Powered by FUDForum. Page generated in 0.03363 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top