Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panache.getEntityManager().merge(obj); returns no error but object is not being persisted to database #46650

Open
t-shaguy opened this issue Mar 6, 2025 · 2 comments

Comments

@t-shaguy
Copy link

t-shaguy commented Mar 6, 2025

@yrodiere , thank you for your feedback. Please find below as requested

  1. high-level description of your problem ( Object to be persisted does not return any errors, returns an incremented value for the PK( auto incremented @id
  2. Any relevant stacktrace (the whole stacktrace) and logs ( no errors or exceptions thrown except when the @transactional annotation is removed
  3. A reproducer,/ repo https://github.com/t-shaguy/cmfb-cu-pin-v2-back-end.git ( just made public)

I have an entity object

https://github.com/entity
https://github.com/table(name="profiles_logs")
public class ProfileSetup extends PanacheEntityBase implements Serializable
{

@id
@GeneratedValue(strategy=GenerationType.IDENTITY)
https://github.com/column(name="tid")
public long tid;

https://github.com/column(name="first_name")
public String firstName;

......
......

and in my Repository I am doing this

@transactional
public ProfileSetup doLog(UserProfileRequest request ) throws Exception {
ProfileSetup profile = null;
try
{

UserProfileRequestObj fromJson = new UserProfileRequestObj(request);

ProfileSetup profilex = doLookUpByName(fromJson.emailAddress,fromJson.mobileNo);

log.info("--doLookUpByParamName -- "+profile);
if(profilex == null)
{

       profile = new ProfileSetup();
       profile.createdDate = LocalDateTime.now();
       profile.emailAddress = fromJson.emailAddress;
       profile.firstName = fromJson.firstName;
       profile.full_name = fromJson.fullName;
       profile.lastName = fromJson.lastName;
       profile.loginStatus = 0;
       profile.mobileNo = fromJson.mobileNo;
       profile.tilAccount   = fromJson.tilAccount;
       profile.status = ResourceStatusEnum.INACTIVE.name();
       profile.userRole = fromJson.userRole;
       //Panache.getEntityManager().merge(profile); // does not return an error for both merge and persist methods , but the object is not written to database
       Panache.getEntityManager().persist(profile);//.merge(profile);
       Panache.getEntityManager().flush();//.getTransaction()..commit();

}
else
{
return profilex;
}

}
catch (Exception e) {
e.printStackTrace();
throw new Exception(e);
}
return profile;
}
Both Panache.getEntityManager().merge(profile) and Panache.getEntityManager().persist(profile) return without errors, and the tid (PK) returns incremented and no errors, however data not persisted to database, I also tried using an Agroal Implementation where I obtained the connection object and used prepared statement executeUpdate() which returned a value of 1, yet no data in my database. Amazingly someother objects are persisting to database in the same project. Please can anyone help?

I have tried the following.

Recreate the database table

  1. Use and Agroal implementation so I can grab the connection object and use prepare statement
  2. Have my entity object extand PanacheEntity and used PanacheEntity.getEntityManager()
  3. All this have not solved the issue
Copy link

quarkus-bot bot commented Mar 6, 2025

/cc @FroMage (panache), @loicmathieu (panache)

@t-shaguy
Copy link
Author

t-shaguy commented Mar 6, 2025

@yrodiere

Apologies, I did not shere the entry point

http://127.0.0.1:9977/cmfb-cu/api/user/create-profile-xx

Payload :

{
"tilAccountNo":"1234567890",
"mobileNo":"+2348036533888",
"emailAddress":"[email protected]",
"actionBy":1,
"lastName":"Tanko",
"userRole":1,
"actionByStr":"[email protected]",
"firstName":"Sally"

}

for this endpoint, I kind of stripped off the function to the basics .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant