I am trying to extend the User entity to add more properties as shown below:
package com.calidus.pdcs.entity;
import io.jmix.core.entity.annotation.CaseConversion;
import io.jmix.core.metamodel.annotation.JmixEntity;import javax.persistence.Column;
import javax.persistence.Entity;@JmixEntity
@Entity
public class ExtendedUser extends User {
@CaseConversion
@Column(name = “EXU_ACRONYM”, length = 4)
private String exuAcronym;public String getExuAcronym() { return exuAcronym; } public void setExuAcronym(String exuAcronym) { this.exuAcronym = exuAcronym; }
}
Then I have a helper class that tries to query the database for the currently logged user, as below:
package com.calidus.pdcs.entity;
import io.jmix.core.DataManager;
import io.jmix.core.security.CurrentAuthentication;
import org.springframework.security.core.userdetails.UserDetails;public interface ExtendedUserHelper {
public static User getCurrentUser(CurrentAuthentication currentAuthentication, DataManager dataManager){
// Returns the currently logged user instance
UserDetails userDetails = currentAuthentication.getUser();
return dataManager.load(User.class)
.query(“select exu from ExtendedUser exu where exu.username = :exun”)
.parameter(“exun”, userDetails.getUsername())
.one();
}
}
The problem is that the currently logged user (admin) is not being found and an exception is being raised by the query.
What is wrong with this implementation?