title: PSQLException: The column index is out of range: 7, number of columns: 6 - Postgres beginner
body: <p>This is a database that I'm building to use with a sample website. </p>
  
  <p>I'm using play 1.3</p>
  
  <p>Here's the structure:</p>
  
  <pre><code>@Entity
  public class BlogUser extends BlogModel {
  
      @Id
      @Column(nullable = false)
      @GeneratedValue(strategy = GenerationType.TABLE)
      public Long id;
  
      public String firstName;
  
      public String lastName;
  
      @Column(nullable = false)
      public String username;
  
      @Column(nullable = false)
      public String password;
  
      @Column(nullable = false)
      public String email;
  
      public BlogUser(String fName, String lName, String uName, String pWord, String email1) {
          firstName = fName;
          lastName = lName;
          username = uName;
          password = pWord;
          email = email1;
      }
  }
  </code></pre>
  
  <p>This is the command from the controller</p>
  
  <pre><code>public static void registerSubmit(String firstName, String lastName, String username, String password, String email) throws FileNotFoundException {
  
      BlogUser user = new BlogUser(firstName, lastName, username, password, email);
  
      //persists the entity in the database
      try {
          user.save();
      }
      catch (PersistenceException e) {
          File file = new File("testsalotofthem.txt");
          PrintStream ps = new PrintStream(file);
          e.printStackTrace(ps);
      }
  }
  </code></pre>
  
  <p>Some of the things have attributes done manually and some don't, that's just me trying to learn all the ways things can be set (what's allowed, what you have to do manually, what can be handled either way).</p>
  
  <p>I'm trying to persist a user in the database. It has all the data, but for some reason it says I'm trying to use 7 columns instead of 6.</p>
  
  <p>The data is coming in from a website and that command is where the information is coming in for the user.</p>
  
  <p>Any tips to fix this would help a lot as I'm stumped.</p>
  
  <p>Here's the stack trace:</p>
  
  <pre><code>javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not insert: [models.BlogUser]
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
  at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316)
  at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:999)
  at play.db.jpa.JPABase._save(JPABase.java:45)
  at play.db.jpa.GenericModel.save(GenericModel.java:232)
  at controllers.Application.registerSubmit(Application.java:50)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:524)
  at play.mvc.ActionInvoker.invoke(ActionInvoker.java:475)
  at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:451)
  at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:446)
  at play.mvc.ActionInvoker.invoke(ActionInvoker.java:160)
  at play.server.PlayHandler$NettyInvocation.execute(PlayHandler.java:267)
  at play.Invoker$Invocation$1.apply(Invoker.java:290)
  at play.Invoker$Invocation$1.apply(Invoker.java:287)
  at play.db.jpa.JPA.withTransaction(JPA.java:258)
  at play.db.jpa.JPA.withinFilter(JPA.java:217)
  at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:299)
  at play.Invoker$Invocation.withinFilter(Invoker.java:271)
  at play.Invoker$Invocation.run(Invoker.java:287)
  at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:245)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
  
  Caused by: org.hibernate.exception.DataException: could not insert: [models.BlogUser]
  at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:135)
  at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
  at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
  at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3087)
  at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3509)
  at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)
  at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:377)
  at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:369)
  at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:286)
  at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339)
  at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
  at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234)
  at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:996)
  ... 28 more
  
  Caused by: org.postgresql.util.PSQLException: The column index is out of range: 7, number of columns: 6.
  at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:53)
  at org.postgresql.core.v3.SimpleParameterList.setLiteralParameter(SimpleParameterList.java:114)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.bindLiteral(AbstractJdbc2Statement.java:2172)
  at org.postgresql.jdbc2.AbstractJdbc2Statement.setLong(AbstractJdbc2Statement.java:1227)
  at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setLong(NewProxyPreparedStatement.java:170)
  at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$1.doBind(BigIntTypeDescriptor.java:57)
  at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:93)
  at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280)
  at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275)
  at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:358)
  at org.hibernate.persister.entity.AbstractEntityPersister.dehydrateId(AbstractEntityPersister.java:2823)
  at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2792)
  at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3064)
  ... 37 more
  </code></pre>
  
  <p>Edit: Added save() method from the play jpa GenericModel.java</p>
  
  <pre><code>public &lt;T extends JPABase&gt; T save() {
      _save();
      return (T) this;
  }
  </code></pre>
  
  <p>Edit2: Added BlogUser Table</p>
  
  <pre><code>            Table "public.bloguser"
    Column   |          Type          | Modifiers 
  -----------+------------------------+-----------
   id        | bigint                 | not null
   email     | character varying(255) | not null
   firstname | character varying(255) | 
   lastname  | character varying(255) | 
   password  | character varying(255) | not null
   username  | character varying(255) | not null
  Indexes:
      "bloguser_pkey" PRIMARY KEY, btree (id)
  </code></pre>