88996

JPA inheritance Could not determine type for

I have a simple JPA mapping but I keep getting a Could not determine type for exception. Setters and getters are omitted.

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class SupervisionCommand {

    @Id
    @GeneratedValue
    protected Long id;

}

@Entity
public class MySupervisionCommand extends SupervisionCommand {

}

@Entity
public class Job {

    @Id
    @GeneratedValue
    private Long id;

    private SupervisionCommand command;

}


The full exception message: Could not determine type for: com.family.model.SupervisionCommand, at table: job, for columns: [org.hibernate.mapping.Column(command)]

Answer1:

You need a OneToOne or ManyToOne annotation (depending on the actual cardinality) on command:

@ManyToOne private SupervisionCommand command;

The default mapping for fields is @Column. And Hibernate doesn't know which type of column to use (varchar? number?) to store a SuperVisionCommand instance. If it implemented Serializable, Hibernate would serialize it and store it in a BLOB column, but this is not what you want.

Recommend

  • rails db:migrate fails '[MODEL].users' doesn't exist: SHOW FULL FIELDS FROM `users`
  • More robust AC_COMPILE_IFELSE feature testing?
  • jQuery - Submit Form to RESTful URL
  • Using asp.net, how do I redirect a user and change the POST data at the same time?
  • paging techniques for datagridview using in winforms applications
  • Clueless about this error: wrong sign in 'by' argument
  • Hibernate get Object by non ID , unique identifier
  • Eclipselink 2.4 + JPA + ManyToMany with additional column
  • Doctrine2 entity with varchar id don't insert id into database
  • How to return objects from multiple entity by joining by using spring data jpa?
  • How to install node-mysql?
  • Suppressing passwd when calling sqlplus from shell script
  • Laravel: Getting Session ID oddly truncates when using foreach
  • Check for zero lines output from command over SSH
  • Bypass multiple inheritance in Java
  • Run multiple queries from 1 SQL file showing result in multiple tables
  • Copy to all folders batch file?
  • Content-Length header not returned from Pylons response
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • Play WS (2.2.1): post/put large request
  • Recording logins for password protected directories
  • How to access EntityManager inside Entity class in EJB3
  • how to do an event when i swipe from fragment to the other
  • Jenkins: How To Build multiple projects from a TFS repository?
  • How do I fake an specific browser client when using Java's Net library?
  • vba code to select only visible cells in specific column except heading
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • jquery mobile loadPage not working
  • Apache 2.4 - remove | delete | uninstall
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Java static initializers and reflection
  • How to stop GridView from loading again when I press back button?
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • How can i traverse a binary tree from right to left in java?
  • Unable to use reactive element in my shiny app
  • How can I use threading to 'tick' a timer to be accessed by other threads?