greenDAO
greenDAO copied to clipboard
greenDAO not generating FOREIGN KEY(…) constraint in table
When I create a bidirectional 1:n relationship as shown below, the generator does not use any FOREIGN KEY(...) constraints on the table.
entity customer = schema.addEntity("Customer"); customer.addIdProperty(); customer.addStringProperty("name").notNull();
Entity order = schema.addEntity("Order"); order.setTableName("ORDERS"); // "ORDER" is a reserved keyword order.addIdProperty(); Property orderDate = order.addDateProperty("date").getProperty(); Property customerId = order.addLongProperty("customerId").notNull().getProperty(); order.addToOne(customer, customerId);
customer.addToMany(order, customerId); Is this normal? Is it supposed to generate FOREIGN KEY(...) constraints in the table for check value
I don't think greenDAO supports Foreign Key constraints. Foreign Key support in SQLite was not added until 3.6.19. Which means it would only be supported in API 8 and up. Since greenDAO supports Android 1.6 and up I would assume that it left out Foreign Key constraints in favor of compatibility.
But I'm with you on adding support for it. :+1:
It could be optional if the SQLite version supports it. If not they could be ignored. API 8 sound reasonable anyway...
I think we can leave in peace api8 and below. even api10. Now time to go forward
We've come up with a greenDAO compatible solution which enforces foreign keys in SQLite. You can read about it on our blog (www.codepandora.com/blog) - How To Enforce Foreign Keys In greenDAO Android ORM
We've come up with a greenDAO compatible solution which enforces foreign keys in SQLite. You can read about it on our blog (www.codepandora.com/blog) - How To Enforce Foreign Keys In greenDAO Android ORM
This link return 520 error.
This has been open since 2015... any plans to support it soon?