No post-init callbacks could complete

Hi guys!
I have encountered a problem when creating controller:

@Named(value = "budgetSourceController")
@RequestScoped
public class BudgetSourceController {

    @Inject
    private SessionInfoBean sessionInfoBean;
    private EntityManager em;

    @PostConstruct
    public void init() {
        em = new JpaEntityManagerFactory(sessionInfoBean.getCurrentDatabase(), Infos.entitiesClasses).getEntityManager();
    }

    public List<Budgetsource> findAll() {
        List<Budgetsource> result = (sessionInfoBean.getCurrentDatabase() == null) ? new ArrayList<>() : em.createNamedQuery("Budgetsource.findAll", Budgetsource.class).getResultList();
        return result;
    }

    public Budgetsource findByBudgetSourceID(String budgetSourceID) {
        Budgetsource result = em.createNamedQuery("Budgetsource.findByBudgetSourceID", Budgetsource.class).setParameter("budgetSourceID", budgetSourceID).getSingleResult();
        return result;
    }

    /*
	 * public List<Budgetsource> findByQuery(String query) { return
	 * em.createNativeQuery(query, Budgetsource.class).getResultList(); }
     */
    public Budgetsource merge(Budgetsource budgetsource) {
        em.getTransaction().begin();
        em.merge(budgetsource);
        em.getTransaction().commit();
        return budgetsource;
    }

    public void persist(Budgetsource budgetsource) {
        em.getTransaction().begin();
        em.persist(budgetsource);
        em.getTransaction().commit();
    }

    public void remove(Budgetsource budgetsource) {
        em.getTransaction().begin();
        em.remove(em.contains(budgetsource) ? budgetsource : em.merge(budgetsource));
        em.getTransaction().commit();
    }

}

When I have executed the application, an exception has occured:

Caused by: java.lang.IllegalStateException: No post-init callbacks could complete
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.executePostInitCallbacks(MappingModelCreationProcess.java:112)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.execute(MappingModelCreationProcess.java:82)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.process(MappingModelCreationProcess.java:33)
	at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:208)
	at org.hibernate.metamodel.internal.RuntimeMetamodelsImpl.finishInitialization(RuntimeMetamodelsImpl.java:47)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:304)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:468)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1263)
	... 111 more

Looks like you are using Hibernate 6.0 which is still a Alpha version and you seem to run into a bug or missing feature. It would be very helpful if you could post your model here so that we can fix this.

Yes I am using Hibernate 6.0. I try to switch from Hibernate 6.0.0.Alpha6 to newer version Hibernate 6.0.0. Alpha9, an error related to foreign key still occurs:

Caused by: org.hibernate.NotYetImplementedFor6Exception: Support for non-pk foreign-keys not yet implemented: com.spf.ibigtime.entities.Babanktransferdetail -> budgetDetailItemCode
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.interpretToOneKeyDescriptor(MappingModelCreationHelper.java:1039)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.setReferencedAttributeForeignKeyDescriptor(MappingModelCreationHelper.java:1249)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.interpretPluralAttributeMappingKeyDescriptor(MappingModelCreationHelper.java:903)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.lambda$buildPluralAttributeMapping$8(MappingModelCreationHelper.java:873)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess$PostInitCallbackEntry.process(MappingModelCreationProcess.java:205)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess$PostInitCallbackEntry.access$000(MappingModelCreationProcess.java:191)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.executePostInitCallbacks(MappingModelCreationProcess.java:108)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.execute(MappingModelCreationProcess.java:90)
	at org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess.process(MappingModelCreationProcess.java:39)
	at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.finishInitialization(MappingMetamodelImpl.java:217)
	at org.hibernate.metamodel.internal.RuntimeMetamodelsImpl.finishInitialization(RuntimeMetamodelsImpl.java:47)
	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:312)
	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1420)
	... 111 more

Below are my entities:
Babanktransferdetail.java

@Entity
@Table(name = "babanktransferdetail")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Babanktransferdetail.findAll", query = "SELECT b FROM Babanktransferdetail b"),
    @NamedQuery(name = "Babanktransferdetail.findByRefDetailID", query = "SELECT b FROM Babanktransferdetail b WHERE b.refDetailID = :refDetailID"),
    @NamedQuery(name = "Babanktransferdetail.findByDescription", query = "SELECT b FROM Babanktransferdetail b WHERE b.description = :description"),
    @NamedQuery(name = "Babanktransferdetail.findByDebitAccount", query = "SELECT b FROM Babanktransferdetail b WHERE b.debitAccount = :debitAccount"),
    @NamedQuery(name = "Babanktransferdetail.findByCreditAccount", query = "SELECT b FROM Babanktransferdetail b WHERE b.creditAccount = :creditAccount"),
    @NamedQuery(name = "Babanktransferdetail.findByFromBankID", query = "SELECT b FROM Babanktransferdetail b WHERE b.fromBankID = :fromBankID"),
    @NamedQuery(name = "Babanktransferdetail.findByToBankID", query = "SELECT b FROM Babanktransferdetail b WHERE b.toBankID = :toBankID"),
    @NamedQuery(name = "Babanktransferdetail.findByAmount", query = "SELECT b FROM Babanktransferdetail b WHERE b.amount = :amount"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetSourceID", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetSourceID = :budgetSourceID"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetChapterCode", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetChapterCode = :budgetChapterCode"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetKindItemCode", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetKindItemCode = :budgetKindItemCode"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetSubKindItemCode", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetSubKindItemCode = :budgetSubKindItemCode"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetItemCode", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetItemCode = :budgetItemCode"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetSubItemCode", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetSubItemCode = :budgetSubItemCode"),
    @NamedQuery(name = "Babanktransferdetail.findByMethodDistributeID", query = "SELECT b FROM Babanktransferdetail b WHERE b.methodDistributeID = :methodDistributeID"),
    @NamedQuery(name = "Babanktransferdetail.findByCashWithDrawTypeID", query = "SELECT b FROM Babanktransferdetail b WHERE b.cashWithDrawTypeID = :cashWithDrawTypeID"),
    @NamedQuery(name = "Babanktransferdetail.findByAccountingObjectID", query = "SELECT b FROM Babanktransferdetail b WHERE b.accountingObjectID = :accountingObjectID"),
    @NamedQuery(name = "Babanktransferdetail.findByActivityID", query = "SELECT b FROM Babanktransferdetail b WHERE b.activityID = :activityID"),
    @NamedQuery(name = "Babanktransferdetail.findByProjectID", query = "SELECT b FROM Babanktransferdetail b WHERE b.projectID = :projectID"),
    @NamedQuery(name = "Babanktransferdetail.findByProjectActivityID", query = "SELECT b FROM Babanktransferdetail b WHERE b.projectActivityID = :projectActivityID"),
    @NamedQuery(name = "Babanktransferdetail.findByListItemID", query = "SELECT b FROM Babanktransferdetail b WHERE b.listItemID = :listItemID"),
    @NamedQuery(name = "Babanktransferdetail.findBySortOrder", query = "SELECT b FROM Babanktransferdetail b WHERE b.sortOrder = :sortOrder"),
    @NamedQuery(name = "Babanktransferdetail.findByAmountOC", query = "SELECT b FROM Babanktransferdetail b WHERE b.amountOC = :amountOC"),
    @NamedQuery(name = "Babanktransferdetail.findByBudgetExpenseID", query = "SELECT b FROM Babanktransferdetail b WHERE b.budgetExpenseID = :budgetExpenseID")})
public class Babanktransferdetail implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "RefDetailID")
    private String refDetailID;
    ......
    @JoinColumn(name = "BudgetDetailItemCode", referencedColumnName = "BudgetItemCode")
    @ManyToOne
    private Budgetitem budgetDetailItemCode; 
    @JoinColumn(name = "FundStructureID", referencedColumnName = "FundStructureID")
    @ManyToOne(optional = false)
    private Fundstructure fundStructureID;
    @JoinColumn(name = "ProjectActivityEAID", referencedColumnName = "ProjectID")
    @ManyToOne(optional = false)
    private Project projectActivityEAID;
    ........

Budgetitem.java

@Entity
@Table(name = "budgetitem")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Budgetitem.findAll", query = "SELECT b FROM Budgetitem b"),
    @NamedQuery(name = "Budgetitem.findByBudgetItemID", query = "SELECT b FROM Budgetitem b WHERE b.budgetItemID = :budgetItemID"),
    @NamedQuery(name = "Budgetitem.findByParentID", query = "SELECT b FROM Budgetitem b WHERE b.parentID = :parentID"),
    @NamedQuery(name = "Budgetitem.findByBudgetItemType", query = "SELECT b FROM Budgetitem b WHERE b.budgetItemType = :budgetItemType"),
    @NamedQuery(name = "Budgetitem.findByBudgetItemCode", query = "SELECT b FROM Budgetitem b WHERE b.budgetItemCode = :budgetItemCode"),
    @NamedQuery(name = "Budgetitem.findByBudgetItemName", query = "SELECT b FROM Budgetitem b WHERE b.budgetItemName = :budgetItemName"),
    @NamedQuery(name = "Budgetitem.findByBudgetGroupItemCode", query = "SELECT b FROM Budgetitem b WHERE b.budgetGroupItemCode = :budgetGroupItemCode"),
    @NamedQuery(name = "Budgetitem.findByGrade", query = "SELECT b FROM Budgetitem b WHERE b.grade = :grade"),
    @NamedQuery(name = "Budgetitem.findByIsParent", query = "SELECT b FROM Budgetitem b WHERE b.isParent = :isParent"),
    @NamedQuery(name = "Budgetitem.findByIsActive", query = "SELECT b FROM Budgetitem b WHERE b.isActive = :isActive")})
public class Budgetitem implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "BudgetItemID")
    private String budgetItemID;
    @Size(max = 64)
    @Column(name = "ParentID")
    private String parentID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BudgetItemType")
    private int budgetItemType;
    @Size(max = 20)
    @Column(name = "BudgetItemCode")
    private String budgetItemCode;
    ........

I also tried the 5.5.7 Final release, but nothing works.

Thanks for the details. The support for this was merged shortly after the release of Alpha9 so maybe the next release will fix this: https://github.com/hibernate/hibernate-orm/commit/d3810b8f7a035a27cf9cbca75d8318a2c551d046

Could you please post details about what doesn’t work with 5.5.7.Final?

Hi All, As we seen, when we upgrade 5.2.x to 6.0.x we found that there is a duplicate jar with different version for hibernate-core . So please consider this point.

Hi All, As we seen, when we upgrade 5.2.x to 6.0.x we found that there is a duplicate jar with different version for hibernate-core . So please consider this point.

If you have an actual issue with Hibernate 6.0, please create a new topic. But if you have multiple hibernate JARs with different version on your class path, then your build is simply doing something wrong.