Closed edmundnoble closed 9 years ago
yeah, it's definitely gnarly. we ran into a problem where to-and-from foreign references would overflow the stack when slick created them. the "pattern" is that any instance of the model should come from the flyweight so that all instances in memory refer to the same object. I didn't write support for creation into the flyweight, so this is our hack to get the right behavior.
lensing the id to the newly returned row id, and putting that in the flyweight would be an okay solution; fixing the flyweight would be better =)
I think I've fixed the flyweight in this respect. I'll open a pull request soon. Let me know if it's broken.
The title. I don't understand this pattern; it looks like a waste of I/O. I'm no Slick expert, though. The problem is a lot of
create()
methods unnecessarily access the database when the data they're looking for is already there.