javax.ejb.EJBException: java.rmi.MarshalException - java

My question is with regards to error messages when i try to create or even view the credit package.
This is the error message that i encountered in glassfish.
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'ABOUT' in 'field list'
Error Code: 1054
Call: SELECT CREDITID, ABOUT, CREDITS, NAME, PACKAGECODE FROM CREDITPACKAGE
Query: ReadAllQuery(referenceClass=CreditPackage sql="SELECT CREDITID, ABOUT, CREDITS, NAME, PACKAGECODE FROM CREDITPACKAGE")
Error message from my own admin client
Caused by: javax.ejb.EJBException: java.rmi.MarshalException: CORBA MARSHAL 1330446393 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: WARNING: 00810057: Could not load class com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException vmcid: OMG minor code: 57 completed: Maybe
at ejb.session.stateless._CreditPackageControllerRemote_Wrapper.retrieveAllCreditPackage(ejb/session/stateless/_CreditPackageControllerRemote_Wrapper.java)
The columns are accounted for, but i'm not sure why it says that unknown column 'ABOUT' in 'field list'
#Entity
public class CreditPackage implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long creditId;
#Column(unique = true)
private String packageCode;
#Column(length = 32, nullable = false)
private String name;
#Column(length = 32, nullable = false)
private String about; //already tried escaping the column name using `` and backslashes
#Column(nullable = false, precision = 18, scale = 4)
private BigDecimal credits;
}
This method is in the controller sessionbean
#Override
public List<CreditPackage> retrieveAllCreditPackage() {
Query query = em.createQuery("SELECT s FROM CreditPackage s"); //Not too sure if this is correct
return query.getResultList();
}
Thank you for reading this! Hopefully there is someone that can help me to resolve this.

Managed to resolve this question with others help.
Turns out i did not regenerate the JDBC database when i added some new columns so the old columns are still there. Hence the exception.
So what i did was:
Delete all the tables in the JDBC database
Redeployed my application system
Run my application client.
Then the error is resolved because it regenerates the new tables in JDBC database according to the new columns.
Hope that it will be helpful to others. Thank you for reading this. :)

Related

Unknown column 'clientproj0_.clienthours_id' in 'field list (JPA #OneToMany(mappedBy = "clienthours"))

I have 2 views
"client_hours_view"
(ClientHoursInfo.java) and
"client_project_hours_view"
(ClientProjectHoursInfo.java)
The first view already existed in the application and :
Retrieves all the clients in the work hours in total
The second view is the new pne and:
Retrieves all the clients with a list of projects for each client and their hours
Anyways, I just want to find a way to retrieve all the clients (first view) with a list of their respective projects (second view), and the best I could figure out is by adding a field list in the ClientHoursInfo.java :
private List clientProjectList which will contain a list of projects for each client.
I have extracted below the code to show only the relation needed against these 2 views
However I am not able to succesfully run it, since it is showing the below error in the console.
Unknown column 'clientproj0_.clienthours_id'
I would like to get guidance to solve this or find a different approach to meet the requirement.
ClientHoursInfo.java
#Entity
#Table(name = "client_hours_view")
public class ClientHoursInfo {
#Id
#Column(name = "unique_id")
private String uniqueId;
private Long id;
private String client;
#Column(name = "week_ending")
private String weekEnding;
#Column(name = "total_hours")
private Double totalHours;
#OneToMany(mappedBy = "clienthours")
private List<ClientProjectHoursInfo> clientProjectList;
}
ClientProjectHoursInfo.java
#Entity
#Table(name = "client_project_hours_view")
public class ClientProjectHoursInfo {
#ManyToOne(fetch = FetchType.LAZY)
private Employee clienthours;
#Id
#Column(name = "id")
private String Id;
}
FinanceManagerReports.java
clientHours = clientHoursInfoViewRepository.findByWeekEndingBetween(from, to);
for (ClientHoursInfo clientHoursInfo : clientHours) {
clientProjectHours = clientProjectHoursInfoViewRepository
.findByClientIdAndWeekEnding(clientHoursInfo.getId(), clientHoursInfo.getWeekEnding());
clientHoursInfo.setClientProjectList(clientProjectHours);
}
Error Console
[2019-10-02 17:21:57.887] boot - 9656 ERROR [http-nio-8080-exec-3] --- SqlExceptionHelper: Unknown column 'clientproj0_.clienthours_id' in 'field list'
[2019-10-02 17:21:57.888] boot - 9656 ERROR [http-nio-8080-exec-3] --- [dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'clientproj0_.clienthours_id' in 'field list'

Hibernate Table not found, MappingException and AssertionException

I tried to map an existing Postgresql Database with Hibernate and it already worked while I didn't add Inheritances per Subclass to Hibernate
This is the superclass
#Entity
#Table(name = "place", schema = "public", catalog = "dbp")
#Inheritance(strategy = InheritanceType.JOINED)
public class PlaceEntity {
private long id;
private String name;
private String url;
// private CityEntity cityById;
private ContinentEntity continentById;
private CountryEntity countryById;
And this is the subclass
#Entity
#Table(name = "city", schema = "public", catalog = "dbp")
#PrimaryKeyJoinColumn(name = "cityid", referencedColumnName = "id")
public class CityEntity extends PlaceEntity{ //WHEN I ADD extends PlaceEntity , THE ERROR OCCURES
private Long cityid;
private Long ispartof;
//private PlaceEntity placeByCityid;
private CountryEntity countryByIspartof;
private Collection<PersonEntity> peopleByCityid;
private Collection<UniversityEntity> universitiesByCityid;
Then Intellij throughs the following exception:
INFO: HHH000270: Type registration [java.util.UUID] overrides previous :org.hibernate.type.UUIDBinaryType#63a12c68
Sep 25, 2017 6:56:11 PM org.hibernate.AssertionFailure <init>
ERROR: HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Table dbprak24.public.place not found
Sep 25, 2017 6:56:11 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH10001008: Cleaning up connection pool [jdbc:postgresql://localhost:5432/dbprak24]
java.lang.ExceptionInInitializerError
at Main.<clinit>(Main.java:22)
Caused by: org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.JoinedSubclassEntityPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:112)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:128)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:297)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
at Main.<clinit>(Main.java:20)
Caused by: org.hibernate.AssertionFailure: Table dbprak24.public.place not found
at org.hibernate.persister.entity.AbstractEntityPersister.getTableId(AbstractEntityPersister.java:5231)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:433)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
... 7 more
Exception in thread "main"
Process finished with exit code 1
I already searched for related problems but couldn't find any solution.
I'd be very glad if anyone could help me :)
Always when i delete
extends PlaceEntity
it runs smoothly and it maps als Tables, place included.
I already invested several days in that problem ^^
Sorry for the strange english, it's not my foreign language :)
Nice evening fellows
Eisenbahnplatte
I have faced the same issue (or something very similiar).
Hibernate 5.2.17.Final + PostgreSQL + Inheritance.JOINED.
Solved it by removing "catalog" attribute from mapping. Try to replace
#Table(name = "place", schema = "public", catalog = "dbp")
with
#Table(name = "place", schema = "public")
Hope this helps.

SQLServerException when persisting entity - index is out of range

I'm having problems persisting an entity with a #OneToOne relationship with another entity. We've recently upgraded to Java 8 with Spring 4 and Hibernate 4 so I'm sure there's some annotation or configuration that has changed.
Relevant code
PermitState.java:
#Entity
#Table(schema = "dbo", name = "PermitState")
public class PermitState implements Serializable {
private String oid;
private Permit permit;
private Integer invoiced;
private Integer used;
private Integer ordered;
private String permitId;
#OneToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "PERMITID")
public Permit getPermit() {
return permit;
}
#Id
#Column(name = "PERMITID", nullable = true, length = 8,insertable = false,updatable = false)
public String getPermitId() {
return permitId;
}
... more getters and setters (irrelevant)
Permit.java:
#Entity
#Table(schema = "dbo")
public class Permit {
private String permitid;
private PermitState permitState;
...some more attributes, irrelevant
#Id
#Column(name = "PERMITID", length = 8)
public String getPermitid() {
return permitid;
}
#OneToOne(mappedBy="permit", cascade=CascadeType.ALL,fetch = FetchType.LAZY)
public PermitState getPermitState() {
return permitState;
}
Stacktrace
Caused by: org.hibernate.exception.GenericJDBCException: could not insert: [dao.srs.model.PermitState]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3099)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3521)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:395)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:387)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:303)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:349)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1195)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:75)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:515)
... 65 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The index 6 is out of range.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:700)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setValue(SQLServerPreparedStatement.java:709)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setString(SQLServerPreparedStatement.java:1034)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setString(NewProxyPreparedStatement.java:963)
at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$1.doBind(VarcharTypeDescriptor.java:57)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:284)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:279)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:343)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrateId(AbstractEntityPersister.java:2835)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2804)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3076)
... 78 more
As you can see, the PermitState entity has both a relation to Permit (via PERMITID, which is the PK in Permit) AND a field called PermitId, which is supposed to the connected Permit's ID. This doesn't seem to work though, it seems that it's trying to insert all 6 attributes even though Permit shouldn't be inserted into the database. I tried to annotate Permit in PermitState with #Transient, but then I get a AnnotationException:
Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: dao.srs.model.Permit.permitState, referenced property unknown: dao.srs.model.PermitState.permit
Any help would be greatly appreciated!
Update
Just to clarify, the DB only have 5 fields - OID, PERMITID, INVOICED, USED and ORDERED - which is why I'm thinking its trying to insert the Permit entity as well. The exact same code without modifications worked when we used Java 7, Spring 3, hibernate-annotations 3.3.1.GA and hibernate-entitymanager 3.3.2.GA. We now use Java 8, Spring 4 and Hibernate core+entitymanager+ehcache 4.2.19.
It seem to me, judging from the exception, that you tried #Transient while still having the #OneToOne and #JoinColumn. That does not really make sense, as you tell Hibernate you want to handle it yourself and that it should handle it also.
Also I find it a bit confusing you both have the Permit entity and the permitId in PermitState. You tell it that you don't want to update permitId, but you still use it as the join column?
I recommend removing the permitId and only have the Permit entity in PermitState. You can still have the getPermitId method if you like, but treat it as an agregate instead.
If all else fails try and log the SQL generated by Hibernate to see what is going on. Perhaps pasting it for us to see.
I think I solved it. I'm still not entirely sure why this works, but it does:
I removed PermitId (the String property) from PermitState.java, and instead used the PermitId from the Permit entitiy in PermitState.
It looks like this:
Permit.java:
private String permitid;
private PermitState permitState;
#OneToOne(mappedBy="permit", cascade=CascadeType.ALL,fetch = FetchType.LAZY)
public PermitState getPermitState() {
return permitState;
}
PermitState.java
private Permit permit;
#OneToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "PERMITID")
public Permit getPermit() {
return permit;
}
Thanks Martin and Bilbo for your help.

Error on compiling query: The abstract schema type 'entity' is unknown

I'm developing a game with a database connection, and I use JPA to persist my data. Here is my Game entity :
#Entity
#Table(name = "game")
public class Game implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "game_id")
private int id;
#Column(name = "name")
private String name;
#Column(name = "nbTurns")
private int nbTurns;
#Column(name = "playedOn")
#Temporal(TemporalType.TIMESTAMP)
private Date playedOn;
#ElementCollection(fetch = FetchType.EAGER)
#CollectionTable(name = "game_humans", joinColumns = #JoinColumn(name = "game_id"))
#MapKeyColumn(name = "human_id")
#Column(name = "isDead")
private Map<Human, Boolean> humans;
And here is my Human entity :
#Entity
#Table(name = "human")
public class Human implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private int id;
#Column(name = "name")
private String name;
#OneToOne
private Building building;
To get the list of all the humans stored in the DB, I use this DAO, which is working very well and gets also the Building entity :
public class HumanDAO implements DAO<Human> {
// ...
public List<Human> getAllHumans() {
TypedQuery<Human> query = em.createQuery("SELECT h FROM human h ORDER BY h.name", Human.class);
return query.getResultList();
}
The problem is when I try to do the same to get the list of all the games with the JPQL query SELECT g FROM game g, I get this error :
[EL Info]: 2013-11-25 13:40:27.761--ServerSession(1943119327)--EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b
[EL Info]: connection: 2013-11-25 13:40:28.151--ServerSession(1943119327)--file:/Users/amine/Documents/workspace/ZombiesServer/target/classes/_ZombiesServer login successful
[WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [SELECT g FROM game g].
[14, 18] The abstract schema type 'game' is unknown.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1605)
at com.amine.zombies.DAO.GameDAO.getAllGames(GameDAO.java:80)
at com.amine.zombies.application.Application.main(Application.java:21)
... 6 more
You should have
SELECT g FROM Game g//you have game
but you have game instead of Game.
The #Table annotation is used for DB.
If you need to change the name in your JPQL, use the #Entity annotation: #Entity(name="nameUsedInJPQL") => nameUsedInJPQL is used in your JPQL.
If you do not specify anything in your #Entity, that the case-sensitive Entity class name is used.
In my case I forgot to register it in persistence.xml.
I just had the very same situation but my JPQL query was correct ! It occured in Glassfish 4.1 (build 13) (with EclipseLink).
After a few googling and some code commenting, I found out that the root cause of "The abstract schema type 'MyEntity' is unknown" was some use of Java 8 lambda code inside the entity class.
It seems that any feature of Java 8 is not (yet) supported in the version of EclipseLink that comes with GF. More info, see the bug report on that.
Hope this helps.
class name should be there not the table name in your query
SELECT g FROM Game g
The name to be used for JPQL queries is defined as the simple name of the entity class - Game or Human in your case. It can be overridden by the name attribute of the #Entity annotation. #Table is a physical mapping annotation and does not influence the entity name in the query.
It does work with human because the query string is not case-sensitive.
We got the problem due to an update of org.eclipse.persistence.eclipselink library from 2.4.0 to 2.5.1. After updating to 2.6.2 it works again.
If you are calling the persistence.xml in a bundle, then org.eclipse.persistence.jpa must be started before your bundle (or bundles). If not, you will get the same exception. You will also see that the tables have not been made in your database. It is therefore a good idea to always add org.eclipse.persistence as an imported package in your manifest.
In my case no answer help me. My JPA project was using Java 14 with EclipseLink 3.0.0 as a provider and seems as EclipseLink doesn´t support new Java versions. Switching back to Java 1.7 did the trick.

JPA generating duplicate keys

I have two entities defined as:
#Entity
public class FileMaster implements java.io.Serializable{
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long fileId;
#NotNull
#Column(unique = true)
private String fileNumber = "";
private String subject = "";
#Temporal(TemporalType.DATE)
private Date date=null;
private String authPerson="";
private String authDesign="";
private String department="";
#OneToMany(mappedBy = "fileMaster", cascade = CascadeType.ALL, orphanRemoval = true)
#JoinColumn(name="id")
private Set<FileDetail> fileDetail = new HashSet<FileDetail>();
and second entity:
#Entity
public class FileDetail implements java.io.Serializable{
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long pdfId;
//#NotNull
#Column(unique = true)
private String name;
//#NotNull
#ManyToOne
private FileMaster fileMaster;
the following code simply tries to persist the two master-detail tables.. First insert goes well and it commits the record:
Set<FileDetail> pdfFileNames = newUpload.getPdfFileNames();
EntityManager em = Persistence.createEntityManagerFactory("fms")
.createEntityManager();
em.getTransaction().begin();
FileMaster fileMaster = new FileMaster();
fileMaster.setFileNumber((String) editorForm.getField("fileNumber").getValue());
fileMaster.setSubject((String) editorForm.getField("subject").getValue());
fileMaster.setAuthDesign((String)
editorForm.getField("authDesign").getValue());
fileMaster.setAuthPerson((String) editorForm.getField("authPerson").getValue());
fileMaster.setDate((Date) editorForm.getField("date").getValue());
fileMaster.setFileDetail(pdfFileNames);
em.persist(fileMaster);
Iterator<FileDetail> iter = pdfFileNames.iterator();
while(iter.hasNext()) {
FileDetail fileDetail = iter.next();
fileDetail.setName(fileDetail.getName());
fileDetail.setFileMaster(fileMaster);
em.persist(fileDetail);
}
em.getTransaction().commit();
em.close();
When I try to insert the second record.... It gives me PSQLException. Since Iam new to JPA... BTW Iam using Eclipselink and PostgreSQL with JPA....Iam finding it hard to resolve this issue. Could anyone please help me over this issue... let me paste the traces as well...
May 27, 2012 10:08:02 AM com.vaadin.Application terminalError
SEVERE: Terminal error:
com.vaadin.event.ListenerMethod$MethodException
Cause: javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "filedetail_pkey"
Detail: Key (pdfid)=(306) already exists.
Error Code: 0
Call: INSERT INTO FILEDETAIL (PDFID, NAME, FILEMASTER_FILEID) VALUES (?, ?, ?)
bind => [306, Manning Java Persistence with Hibernate 2nd.pdf, 3]
Query: InsertObjectQuery(Manning Java Persistence with Hibernate 2nd.pdf)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:532)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.Button.fireClick(Button.java:550)
at com.vaadin.ui.Button.changeVariables(Button.java:217)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1451)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1399)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1318)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:763)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:598)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:486)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
at org.eclipse.jetty.server.Server.handle(Server.java:350)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:900)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:954)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "filedetail_pkey"
Detail: Key (pdfid)=(306) already exists.
Error Code: 0
Call: INSERT INTO FILEDETAIL (PDFID, NAME, FILEMASTER_FILEID) VALUES (?, ?, ?)
bind => [306, Manning Java Persistence with Hibernate 2nd.pdf, 3]
Query: InsertObjectQuery(Manning Java Persistence with Hibernate 2nd.pdf)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(Entit yTransactionImpl.java:102)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransac tionImpl.java:63)
at com.complete.raspberry.webui.PersonEditor.save(PersonEditor.java:178)
at com.complete.raspberry.webui.PersonEditor.buttonClick(PersonEditor.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
... 36 more
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
You should use GenerationType.IDENTITY to generate pdfid using auto increment instead of GenerationType.AUTO for FileDetail entity.
#Entity
public class FileDetail implements java.io.Serializable{
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long pdfId;
}
GenerationType.IDENTITY
Indicates that the persistence provider must assign primary keys for
the entity using a database identity column.
Try setting logging on finest to see what is occurring.
Where does pdfFileNames come from? Are this existing objects, with existing ids? If they are existing, you should either be find/merging them, or create new ones with null ids. Ensure they do not have existing ids when you call persist.
If using SEQUENCE also ensure your increment matches your allocation size (default is 50).

Categories

Resources