question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enums as composite primary key

See original GitHub issue

DBFlow Version: 4.0.4, 4.0.5 Issue Kind : Question

Description:

I get a <identifier> expected error if I have use enum as primary key. Looks like there is a problem with Enums as primary keys or should we handle them differently?

public class Contact {
    @NotNull
    @PrimaryKey
    Long userId;

    @NotNull
    @PrimaryKey
    ContactType type; // Enum
   
    @Column
    String name;
    ...
}

public class User {
    @PrimaryKey
    Long id;
    @ForeignKey(saveForeignKeyModel = true,
            deleteForeignKeyModel = true,
            tableClass = TaskAddress.class,
            onDelete = ForeignKeyAction.SET_NULL,
            onUpdate = ForeignKeyAction.CASCADE)
   Contact contact;
   ...
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
agrosnercommented, Aug 26, 2017

it seems that I either fixed it or decided to support enums as primary keys. can you check with latest 32dd5e19c to see if issue is still happening?

1reaction
agrosnercommented, Jul 25, 2017

I will ensure that the error message appears.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Composite primary key for a String and an enum type variable
Create one more class, which you can then use as your primary key. To do this you must use @EmbeddedId. Your class:
Read more >
Enum used for a primary key pair - CodeRanch
I encounter a problem when i used Enum type for primary key pair. Does anyone have experienc ... usually it is ok to...
Read more >
ENUM and ID as a Foreign Key - DBA Stack Exchange
I'm working on a database design and have arrived at a schema that uses a generic "join table". This join table contains five...
Read more >
[JPA-7] JPA Support of Enum as Primary Key - Hibernate JIRA
Enums work as primary keys in TopLink and EclipseLink. DataNucleus supports them, too: http://www.datanucleus.org/products/accessplatform/jpa/primary_key.
Read more >
Composite key field is not a simple type or enum — oracle-tech
According to the docs here - http://www.oracle.com/technology/documentation/berkeley-db/je/java/index.html?com/sleepycat/persist/model/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found