facebook

Want to reverse engineer SQL enum into JPA enum

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #287899 Reply

    tigato
    Member

    I’m trying to take a table with a column with an ENUM type and reverse engineer it into a JPA persistence class that has a type safe enum, but it comes out as a string instead.

    I tried creating the Enum, putting it in the same directory, and putting it in the jpa.reveng.xml file, but I get an error saying:
    java.lang.IllegalArgumentException: No enum const class ….

    I saw some other posts that say we also need to manually put the @Enumerated(EnumType.STRING) before the getter like this:

    @Enumerated(value=EnumType.STRING)
    @Column(name = “type”, unique = false, nullable = false, insertable = true, updatable = true, length = 11)
    public ContactDeviceType getType() {
    return this.type;
    }

    However, that doesn’t seem to make a difference. What do I need to do to make this work?

    #287949 Reply

    Brian Fernandes
    Moderator

    tigato,

    I’m afraid by default the tool will not generate Enumerations for you as there isn’t enough metadata for that to happen. Can you tell me what you actually tried to do in jpa.reveng.xml?

    I see your snippet above, is this prefect code you would like generated or is this code that you are currently using (after manual modification) and it still is not working?
    If you can answer the above questions we may be able to suggest a way in which the tool can generate desired code for you.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Want to reverse engineer SQL enum into JPA enum

You must be logged in to post in the forum log in