How to Create One to many and many to many relationship on same bean class using spring with hibernate template

Our First Entity Bean Class.
I am using hibernate 5, spring 5, and i am trying to implement this with hibernate tamplate in spring.

@Entity
@Table(name = "visamanagmenttable")
@DynamicUpdate 
@SelectBeforeUpdate(true)
public class VisaManagementBean {

    @Id
    @Column(name = "visaManageId")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int visaManageId;

    @Column(name = "countryName")
    private String countryName;

    @Column(name = "visaUniqueId")
    private String visaUniqueId;

    @Column(name = "visaCategory")
    private int visaCategory;

    @Column(name = "visaVarientName")
    private String visaVarientName;

    @Column(name = "visaGovernmentFee")
    private String visaGovernmentFee;

    @Column(name = "visaServiceFee")
    private String visaServiceFee;

    @Column(name = "visaSecurityDepositFee")
    private String visaSecurityDepositFee;

    @Column(name = "visaAdditionalFee")
    private String visaAdditionalFee;

    @Column(name = "visaAdditionalRemark")
    private String visaAdditionalRemark;

    @Column(name = "visaSecurityDepositRemark")
    private String visaSecurityDepositRemark;

    @Column(name = "visaMode")
    private String visaMode;

    @Column(name = "visaCitizenShipCountry")
    private String visaCitizenShipCountry;

    @Column(name = "visaLivingCountry")
    private String visaLivingCountry;

    @Column(name = "visaDescription")
    private String visaDescription;

    @Column(name = "visaStatus")
    private String visaStatus;

    @Column(name="createdBy", updatable=false)
    private String createdBy;

    @Column(name="modifiedBy")
    private String modifiedBy;

    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="creationDate",updatable=false)
    private Date creationDate;

    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="modifiedDate")
    private Date modifiedDate;

    @Column(name = "status")
    private String status;  

    @Transient
    private String[] citizencountry;

    @Transient
    private String[] livingcountry;

    public int getVisaManageId() {
        return visaManageId;
    }

    public String getVisaUniqueId() {
        return visaUniqueId;
    }

    public int getVisaCategory() {
        return visaCategory;
    }

    public String getVisaVarientName() {
        return visaVarientName;
    }

    public String getVisaGovernmentFee() {
        return visaGovernmentFee;
    }

    public String getVisaServiceFee() {
        return visaServiceFee;
    }

    public String getVisaSecurityDepositFee() {
        return visaSecurityDepositFee;
    }

    public String getVisaAdditionalFee() {
        return visaAdditionalFee;
    }

    public String getVisaAdditionalRemark() {
        return visaAdditionalRemark;
    }

    public String getVisaSecurityDepositRemark() {
        return visaSecurityDepositRemark;
    }

    public String getVisaMode() {
        return visaMode;
    }

    public String getVisaCitizenShipCountry() {
        return visaCitizenShipCountry;
    }

    public String getVisaLivingCountry() {
        return visaLivingCountry;
    }

    public String getVisaDescription() {
        return visaDescription;
    }

    public String getVisaStatus() {
        return visaStatus;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public String getStatus() {
        return status;
    }

    public void setVisaManageId(int visaManageId) {
        this.visaManageId = visaManageId;
    }

    public void setVisaUniqueId(String visaUniqueId) {
        this.visaUniqueId = visaUniqueId;
    }

    public void setVisaCategory(int visaCategory) {
        this.visaCategory = visaCategory;
    }

    public void setVisaVarientName(String visaVarientName) {
        this.visaVarientName = visaVarientName;
    }

    public void setVisaGovernmentFee(String visaGovernmentFee) {
        this.visaGovernmentFee = visaGovernmentFee;
    }

    public void setVisaServiceFee(String visaServiceFee) {
        this.visaServiceFee = visaServiceFee;
    }

    public void setVisaSecurityDepositFee(String visaSecurityDepositFee) {
        this.visaSecurityDepositFee = visaSecurityDepositFee;
    }

    public void setVisaAdditionalFee(String visaAdditionalFee) {
        this.visaAdditionalFee = visaAdditionalFee;
    }

    public void setVisaAdditionalRemark(String visaAdditionalRemark) {
        this.visaAdditionalRemark = visaAdditionalRemark;
    }

    public void setVisaSecurityDepositRemark(String visaSecurityDepositRemark) {
        this.visaSecurityDepositRemark = visaSecurityDepositRemark;
    }

    public void setVisaMode(String visaMode) {
        this.visaMode = visaMode;
    }

    public void setVisaCitizenShipCountry(String visaCitizenShipCountry) {
        this.visaCitizenShipCountry = visaCitizenShipCountry;
    }

    public void setVisaLivingCountry(String visaLivingCountry) {
        this.visaLivingCountry = visaLivingCountry;
    }

    public void setVisaDescription(String visaDescription) {
        this.visaDescription = visaDescription;
    }

    public void setVisaStatus(String visaStatus) {
        this.visaStatus = visaStatus;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public void setModifiedBy(String modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

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

    public String getCountryName() {
        return countryName;
    }

    public void setCountryName(String countryName) {
        this.countryName = countryName;
    }

    public String[] getCitizencountry() {
        return citizencountry;
    }

    public String[] getLivingcountry() {
        return livingcountry;
    }

    public void setCitizencountry(String[] citizencountry) {
        this.citizencountry = citizencountry;
    }

    public void setLivingcountry(String[] livingcountry) {
        this.livingcountry = livingcountry;
    }       

}

CitizenCountryBean has relationship between visa management bean (One to Many)

@Entity
@Table(name = "citizencountrytable")
@DynamicUpdate
@SelectBeforeUpdate(true)
public class CitizenCountryBean {

    @Id
    @Column(name = "citizenId")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int citizenId;

    @Column(name = "citizencountryName")
    private String citizencountryName;

    @OneToMany(targetEntity = VisaManagementBean.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "citizenId", referencedColumnName = "citizenId")
    private Set<VisaManagementBean> visaManagementList = new HashSet<VisaManagementBean>();

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
    private Set<LivingCountryBean> livingCountryBeanList= new HashSet<>();

    @Column(name="createdBy", updatable=false)
    private String createdBy;

    @Column(name="modifiedBy")
    private String modifiedBy;

    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="creationDate",updatable=false)
    private Date creationDate;

    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="modifiedDate")
    private Date modifiedDate;

    @Column(name = "status")
    private String status;

    public int getCitizenId() {
        return citizenId;
    }

    public String getCitizencountryName() {
        return citizencountryName;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public String getStatus() {
        return status;
    }

    public void setCitizenId(int citizenId) {
        this.citizenId = citizenId;
    }

    public void setCitizencountryName(String citizencountryName) {
        this.citizencountryName = citizencountryName;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public void setModifiedBy(String modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

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

    public Set<LivingCountryBean> getLivingCountryBeanList() {
        return livingCountryBeanList;
    }

    public Set<VisaManagementBean> getVisaManagementList() {
        return visaManagementList;
    }

    public void setLivingCountryBeanList(Set<LivingCountryBean> livingCountryBeanList) {
        this.livingCountryBeanList = livingCountryBeanList;
    }

    public void setVisaManagementList(Set<VisaManagementBean> visaManagementList) {
        this.visaManagementList = visaManagementList;
    }

}

our 3rd bean Class LivingCountryBean and Cityzenshipship we have relationship many to many. Our all data inserted successfully in respective tables but our 3rd table that was created by hibernate from many to many relation we are getting null values.

@Entity
@Table(name = "livingcountrytable")
@DynamicUpdate 
@SelectBeforeUpdate(true)
public class LivingCountryBean {

    @Id
    @Column(name = "livingId")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int livingId;

    @Column(name = "livingcountryName")
    private String livingcountryName;

    @ManyToMany(mappedBy="livingCountryBeanList")
    private Set<CitizenCountryBean> citizenCountryBeanList= new HashSet<>();

    @Column(name="createdBy", updatable=false)
    private String createdBy;

    @Column(name="modifiedBy")
    private String modifiedBy;

    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="creationDate",updatable=false)
    private Date creationDate;

    @UpdateTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="modifiedDate")
    private Date modifiedDate;

    @Column(name = "status")
    private String status;

    public int getLivingId() {
        return livingId;
    }

    public String getLivingcountryName() {
        return livingcountryName;
    }

    public Set<CitizenCountryBean> getCitizenCountryBeanList() {
        return citizenCountryBeanList;
    }

    public void setCitizenCountryBeanList(Set<CitizenCountryBean> citizenCountryBeanList) {
        this.citizenCountryBeanList = citizenCountryBeanList;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public String getModifiedBy() {
        return modifiedBy;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public String getStatus() {
        return status;
    }

    public void setLivingId(int livingId) {
        this.livingId = livingId;
    }

    public void setLivingcountryName(String livingcountryName) {
        this.livingcountryName = livingcountryName;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public void setModifiedBy(String modifiedBy) {
        this.modifiedBy = modifiedBy;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

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

}
How we are working on our DAOService Implementation 
@Override
        public int createVisaManagement(CitizenCountryBean citizenCountryBean) {
            Integer id = (Integer) hibernateTemplate.save(citizenCountryBean);
            return id;
        }

As I already explained you on Twitter, you need to:

  1. Add the data access code in the question, so I don’t know how you persisted the entities.
  2. Add the SQL logs generated by Hibernate.

Here is my DAO Service Impl.

@Override
        public int createVisaManagement(CitizenCountryBean citizenCountryBean) {
            Integer id = (Integer) hibernateTemplate.save(citizenCountryBean);
            return id;
        }
[EntityIdentityInsertAction[com.touristvisaonline.DAOBeans.CitizenCountryBean#<null>]]
[2019-01-15 17:51:27,577] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Executing insertions before resolved early-insert
[2019-01-15 17:51:27,577] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue DEBUG - Executing identity-insert immediately
[2019-01-15 17:51:27,577] http-nio-8080-exec-27 org.hibernate.persister.entity.AbstractEntityPersister TRACE - Inserting entity: com.touristvisaonline.DAOBeans.CitizenCountryBean (native id)
[2019-01-15 17:51:27,577] http-nio-8080-exec-27 org.hibernate.SQL DEBUG - 
    insert 
    into
        citizencountrytable
        (citizencountryName, createdBy, creationDate, modifiedBy, modifiedDate, status) 
    values
        (?, ?, ?, ?, ?, ?)
[2019-01-15 17:51:27,590] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Registering statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into citizencountrytable (citizencountryName, createdBy, creationDate, modifiedBy, modifiedDate, status) values (** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **)]
[2019-01-15 17:51:27,590] http-nio-8080-exec-27 org.hibernate.persister.entity.AbstractEntityPersister TRACE - Dehydrating entity: [com.touristvisaonline.DAOBeans.CitizenCountryBean#<null>]
[2019-01-15 17:51:27,590] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [1] as [VARCHAR] - [ad]
[2019-01-15 17:51:27,590] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [2] as [VARCHAR] - [vivek]
[2019-01-15 17:51:27,590] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [3] as [TIMESTAMP] - [Tue Jan 15 17:51:27 IST 2019]
[2019-01-15 17:51:27,591] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [4] as [VARCHAR] - [null]
[2019-01-15 17:51:27,592] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [5] as [TIMESTAMP] - [Tue Jan 15 17:51:27 IST 2019]
[2019-01-15 17:51:27,592] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [6] as [VARCHAR] - [Active]
[2019-01-15 17:51:27,619] http-nio-8080-exec-27 org.hibernate.id.IdentifierGeneratorHelper DEBUG - Natively generated identity: 9
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing result set [com.mysql.cj.jdbc.result.ResultSetImpl@1bbc6312]
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl DEBUG - HHH000387: ResultSet's statement was not registered
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Closing result set [com.mysql.cj.jdbc.result.ResultSetImpl@1bbc6312]
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into citizencountrytable (citizencountryName, createdBy, creationDate, modifiedBy, modifiedDate, status) values ('ad', 'vivek', '2019-01-15 17:51:27.577', null, '2019-01-15 17:51:27.577', 'Active')]
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Closing prepared statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into citizencountrytable (citizencountryName, createdBy, creationDate, modifiedBy, modifiedDate, status) values ('ad', 'vivek', '2019-01-15 17:51:27.577', null, '2019-01-15 17:51:27.577', 'Active')]
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl TRACE - Starting after statement execution processing [ON_CLOSE]
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.engine.internal.Cascade TRACE - Processing cascade ACTION_SAVE_UPDATE for: com.touristvisaonline.DAOBeans.CitizenCountryBean
[2019-01-15 17:51:27,620] http-nio-8080-exec-27 org.hibernate.engine.internal.Cascade TRACE - Cascade ACTION_SAVE_UPDATE for collection: com.touristvisaonline.DAOBeans.CitizenCountryBean.livingCountryBeanList
[2019-01-15 17:51:27,621] http-nio-8080-exec-27 org.hibernate.engine.spi.CascadingAction TRACE - Cascading to save or update: com.touristvisaonline.DAOBeans.LivingCountryBean
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.engine.spi.IdentifierValue TRACE - ID unsaved-value: 0
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.event.internal.AbstractSaveEventListener TRACE - Transient instance of: com.touristvisaonline.DAOBeans.LivingCountryBean
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.event.internal.DefaultSaveOrUpdateEventListener TRACE - Saving transient instance
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.event.internal.AbstractSaveEventListener TRACE - Saving [com.touristvisaonline.DAOBeans.LivingCountryBean#<null>]
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.event.internal.WrapVisitor TRACE - Wrapped collection in role: com.touristvisaonline.DAOBeans.LivingCountryBean.citizenCountryBeanList
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Adding an EntityIdentityInsertAction for [com.touristvisaonline.DAOBeans.LivingCountryBean] object
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Executing inserts before finding non-nullable transient entities for early insert: [EntityIdentityInsertAction[com.touristvisaonline.DAOBeans.LivingCountryBean#<null>]]
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Adding insert with no non-nullable, transient entities: [EntityIdentityInsertAction[com.touristvisaonline.DAOBeans.LivingCountryBean#<null>]]
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Executing insertions before resolved early-insert
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue DEBUG - Executing identity-insert immediately
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.persister.entity.AbstractEntityPersister TRACE - Inserting entity: com.touristvisaonline.DAOBeans.LivingCountryBean (native id)
[2019-01-15 17:51:27,622] http-nio-8080-exec-27 org.hibernate.SQL DEBUG - 
    insert 
    into
        livingcountrytable
        (createdBy, creationDate, livingcountryName, modifiedBy, modifiedDate, status) 
    values
        (?, ?, ?, ?, ?, ?)
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Registering statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into livingcountrytable (createdBy, creationDate, livingcountryName, modifiedBy, modifiedDate, status) values (** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **)]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.persister.entity.AbstractEntityPersister TRACE - Dehydrating entity: [com.touristvisaonline.DAOBeans.LivingCountryBean#<null>]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [1] as [VARCHAR] - [vivek]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [2] as [TIMESTAMP] - [Tue Jan 15 17:51:27 IST 2019]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [3] as [VARCHAR] - [dz]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [4] as [VARCHAR] - [null]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [5] as [TIMESTAMP] - [Tue Jan 15 17:51:27 IST 2019]
[2019-01-15 17:51:27,623] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [6] as [VARCHAR] - [Active]
[2019-01-15 17:51:27,626] http-nio-8080-exec-27 org.hibernate.id.IdentifierGeneratorHelper DEBUG - Natively generated identity: 9
[2019-01-15 17:51:27,626] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing result set [com.mysql.cj.jdbc.result.ResultSetImpl@1ff29c0f]
[2019-01-15 17:51:27,626] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl DEBUG - HHH000387: ResultSet's statement was not registered
[2019-01-15 17:51:27,626] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Closing result set [com.mysql.cj.jdbc.result.ResultSetImpl@1ff29c0f]
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into livingcountrytable (createdBy, creationDate, livingcountryName, modifiedBy, modifiedDate, status) values ('vivek', '2019-01-15 17:51:27.622', 'dz', null, '2019-01-15 17:51:27.622', 'Active')]
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Closing prepared statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into livingcountrytable (createdBy, creationDate, livingcountryName, modifiedBy, modifiedDate, status) values ('vivek', '2019-01-15 17:51:27.622', 'dz', null, '2019-01-15 17:51:27.622', 'Active')]
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl TRACE - Starting after statement execution processing [ON_CLOSE]
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.internal.Cascade TRACE - Done cascade ACTION_SAVE_UPDATE for collection: com.touristvisaonline.DAOBeans.CitizenCountryBean.livingCountryBeanList
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.internal.Cascade TRACE - Cascade ACTION_SAVE_UPDATE for collection: com.touristvisaonline.DAOBeans.CitizenCountryBean.visaManagementList
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.spi.CascadingAction TRACE - Cascading to save or update: com.touristvisaonline.DAOBeans.VisaManagementBean
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.spi.IdentifierValue TRACE - ID unsaved-value: 0
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.event.internal.AbstractSaveEventListener TRACE - Transient instance of: com.touristvisaonline.DAOBeans.VisaManagementBean
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.event.internal.DefaultSaveOrUpdateEventListener TRACE - Saving transient instance
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.event.internal.AbstractSaveEventListener TRACE - Saving [com.touristvisaonline.DAOBeans.VisaManagementBean#<null>]
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Adding an EntityIdentityInsertAction for [com.touristvisaonline.DAOBeans.VisaManagementBean] object
[2019-01-15 17:51:27,627] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Executing inserts before finding non-nullable transient entities for early insert: [EntityIdentityInsertAction[com.touristvisaonline.DAOBeans.VisaManagementBean#<null>]]
[2019-01-15 17:51:27,628] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Adding insert with no non-nullable, transient entities: [EntityIdentityInsertAction[com.touristvisaonline.DAOBeans.VisaManagementBean#<null>]]
[2019-01-15 17:51:27,628] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue TRACE - Executing insertions before resolved early-insert
[2019-01-15 17:51:27,628] http-nio-8080-exec-27 org.hibernate.engine.spi.ActionQueue DEBUG - Executing identity-insert immediately
[2019-01-15 17:51:27,628] http-nio-8080-exec-27 org.hibernate.persister.entity.AbstractEntityPersister TRACE - Inserting entity: com.touristvisaonline.DAOBeans.VisaManagementBean (native id)
[2019-01-15 17:51:27,628] http-nio-8080-exec-27 org.hibernate.SQL DEBUG - 
    insert 
    into
        visamanagmenttable
        (countryName, createdBy, creationDate, modifiedBy, modifiedDate, status, visaAdditionalFee, visaAdditionalRemark, visaCategory, visaCitizenShipCountry, visaDescription, visaGovernmentFee, visaLivingCountry, visaMode, visaSecurityDepositFee, visaSecurityDepositRemark, visaServiceFee, visaStatus, visaUniqueId, visaVarientName) 
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[2019-01-15 17:51:27,629] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Registering statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into visamanagmenttable (countryName, createdBy, creationDate, modifiedBy, modifiedDate, status, visaAdditionalFee, visaAdditionalRemark, visaCategory, visaCitizenShipCountry, visaDescription, visaGovernmentFee, visaLivingCountry, visaMode, visaSecurityDepositFee, visaSecurityDepositRemark, visaServiceFee, visaStatus, visaUniqueId, visaVarientName) values (** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **, ** NOT SPECIFIED **)]
[2019-01-15 17:51:27,629] http-nio-8080-exec-27 org.hibernate.persister.entity.AbstractEntityPersister TRACE - Dehydrating entity: [com.touristvisaonline.DAOBeans.VisaManagementBean#<null>]
[2019-01-15 17:51:27,629] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [1] as [VARCHAR] - [in]
[2019-01-15 17:51:27,629] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [2] as [VARCHAR] - [vivek]
[2019-01-15 17:51:27,629] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [3] as [TIMESTAMP] - [Tue Jan 15 17:51:27 IST 2019]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [4] as [VARCHAR] - [null]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [5] as [TIMESTAMP] - [Tue Jan 15 17:51:27 IST 2019]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [6] as [VARCHAR] - [Block]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [7] as [VARCHAR] - [100]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [8] as [VARCHAR] - [100]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [9] as [INTEGER] - [3]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [10] as [VARCHAR] - [ad]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [11] as [VARCHAR] - [<p>Testin</p>
]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [12] as [VARCHAR] - [100]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [13] as [VARCHAR] - [dz]
[2019-01-15 17:51:27,630] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [14] as [VARCHAR] - [Sticker Visa]
[2019-01-15 17:51:27,631] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [15] as [VARCHAR] - [100]
[2019-01-15 17:51:27,631] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [16] as [VARCHAR] - [100]
[2019-01-15 17:51:27,631] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [17] as [VARCHAR] - [100]
[2019-01-15 17:51:27,631] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [18] as [VARCHAR] - [Not Required]
[2019-01-15 17:51:27,631] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [19] as [VARCHAR] - [null]
[2019-01-15 17:51:27,631] http-nio-8080-exec-27 org.hibernate.type.descriptor.sql.BasicBinder TRACE - binding parameter [20] as [VARCHAR] - [null]
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.id.IdentifierGeneratorHelper DEBUG - Natively generated identity: 9
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing result set [com.mysql.cj.jdbc.result.ResultSetImpl@42108188]
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl DEBUG - HHH000387: ResultSet's statement was not registered
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Closing result set [com.mysql.cj.jdbc.result.ResultSetImpl@42108188]
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into visamanagmenttable (countryName, createdBy, creationDate, modifiedBy, modifiedDate, status, visaAdditionalFee, visaAdditionalRemark, visaCategory, visaCitizenShipCountry, visaDescription, visaGovernmentFee, visaLivingCountry, visaMode, visaSecurityDepositFee, visaSecurityDepositRemark, visaServiceFee, visaStatus, visaUniqueId, visaVarientName) values ('in', 'vivek', '2019-01-15 17:51:27.628', null, '2019-01-15 17:51:27.628', 'Block', '100', '100', 3, 'ad', '<p>Testin</p>\r\n', '100', 'dz', 'Sticker Visa', '100', '100', '100', 'Not Required', null, null)]
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Closing prepared statement [com.mysql.cj.jdbc.ClientPreparedStatement: insert into visamanagmenttable (countryName, createdBy, creationDate, modifiedBy, modifiedDate, status, visaAdditionalFee, visaAdditionalRemark, visaCategory, visaCitizenShipCountry, visaDescription, visaGovernmentFee, visaLivingCountry, visaMode, visaSecurityDepositFee, visaSecurityDepositRemark, visaServiceFee, visaStatus, visaUniqueId, visaVarientName) values ('in', 'vivek', '2019-01-15 17:51:27.628', null, '2019-01-15 17:51:27.628', 'Block', '100', '100', 3, 'ad', '<p>Testin</p>\r\n', '100', 'dz', 'Sticker Visa', '100', '100', '100', 'Not Required', null, null)]
[2019-01-15 17:51:27,636] http-nio-8080-exec-27 org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl TRACE - Starting after statement execution processing [ON_CLOSE]
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.engine.internal.Cascade TRACE - Done cascade ACTION_SAVE_UPDATE for collection: com.touristvisaonline.DAOBeans.CitizenCountryBean.visaManagementList
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.engine.internal.Cascade TRACE - Done processing cascade ACTION_SAVE_UPDATE for: com.touristvisaonline.DAOBeans.CitizenCountryBean
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.internal.SessionImpl TRACE - Closing session [78e5fb1c-d3ad-44b7-9f5a-cd6dd574d58c]
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl TRACE - Closing JDBC container [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl@2d654607]
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing JDBC resources
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl TRACE - Closing logical connection
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl TRACE - Releasing JDBC resources
[2019-01-15 17:51:27,637] http-nio-8080-exec-27 org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl TRACE - Logical connection closed

How is the citizenCountryBean created? Are you synchronizing both ends of the bidirectional association?

Also, show us in the SQL query what’s wrong. Which values are null and they should not be?

1 Like

@vlad I have resolved my issue by my concern was. Actually i was trying to use spring-orm (In spring i am using hibernate template that was provided by spring orm ) so i am directly tried to save an entity as shown in my DAO Service Impl. but later i tired to get hibernate session in my DAO Service method and tried to save an entity its automatically get inserted values inside my relation table that was created by many to many relation.
Yes i am used both ends of the bidirectional association.

I am very thankful for you kind response & helping out.

You’re welcome. I’m glad you found the solution.