Hibernate 6.4.10 Issue with mapping repeated foreign keys with Column and ManyToOne

I have an entity that looks like this

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

  @Id
  @GeneratedValue(generator = "generator")
  @GenericGenerator(
      name = "generator",
      strategy = "some.class.to.generate.ids")
  @Column(name = "setting_id")
  private Long settingId;

  @Column(name = "config_id")
  private long configId;

  @Column(name = "desc", nullable = false, length = 29)
  @Builder.Default
  private String desc = "";

  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "override_id", updatable = false, insertable = false)
  private OverrideData override;

  @Column(name = "override_id")
  private Long overrideId;

  @Column(name = "pcs_id")
  private Long pcsId;

  @ManyToOne(fetch = FetchType.EAGER)
  @JoinColumn(name = "pcs_id", updatable = false, insertable = false)
  private PCS pcs;
}

The motivation to have 2 mappings for override_id and pcs_id is often when creating new settings I just want to specify the ids, not have to define/query a whole other entity. But when reading, I basically always want override/pcs to be set.

My problem is with configId. For some reason, its always fetching null even though this column is always populated in the database.

org.hibernate.PropertyAccessException: Null value was assigned to a property [class ConfigSetting.configId] of primitive type: 'ConfigSetting.configId' (setter)

	at org.hibernate.property.access.spi.SetterFieldImpl.set(SetterFieldImpl.java:63)
	at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:4467)
	at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntityInstance(AbstractEntityInitializer.java:853)
	at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntity(AbstractEntityInitializer.java:813)
	at org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeInstance(AbstractEntityInitializer.java:799)
	at org.hibernate.sql.results.internal.InitializersList.initializeInstance(InitializersList.java:70)
	at org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:109)
	at org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:86)

If I add this other ManyToOne mapping

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "config_id", nullable = false, updatable = false, insertable = false)
private Config config;

now config_id is populated correctly and this error disappears. Any idea’s what’s going on? I’d rather not add this additional config field since I dont want client code to edit configs through settings

EDIT: seems like setting FetchType.LAZY instead of eager also makes the issue go away

First of all, please update to the latest ORM 6.6 or 7.0 version, since 6.4 is not supported in the community anymore. If you still run into trouble then, please try to create a reproducer with our test case template and if you are able to reproduce the issue, create a bug ticket in our issue tracker and attach that reproducer.