I am creating a Author Entity and trying to persist, getting the ivalid object database exception.
Here is my code.
@Entity
@Table(name = "AuthDetails")
public class Author {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
private String firstName;
private String lastName;
private LocalDate dateOfBirth;
@Transient
private Integer age;
Author() {
}
Author(String firstName, String lastName, LocalDate dateOfBirth) {
this.firstName = firstName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
}
}
Persistence.xml i have defined the Author.
I am calling as below:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("bookPU");
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
LocalDate date = LocalDate.of(1984, 04, 23);
em.persist(new Author("ABC","XYZ",date));
tx.commit();
Getting exception as below:
nternal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'AuthDetails'.
Error Code: 208
Call: INSERT INTO AuthDetails (ID, DATEOFBIRTH, FIRSTNAME, LASTNAME) VALUES (?, ?, ?, ?)
bind => [4 parameters bound]
Query: InsertObjectQuery(lok.learning.jpademo.callback.Author@2c991465)
Exception in thread "main" javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.6.v20200131-b7c997804f): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'AuthDetails'.
Error Code: 208
Any help
question from:
https://stackoverflow.com/questions/66056822/jpaeclipselink-invalid-object-while-persisting 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…