What Scala feature can help a class become a factory? And return persistent objects like database connections?
I am most familiar with Python, less familiar with Java and spent only a few hours with Scala (tutorials). I am working the counter-intuitive ideas about Scala classes into my head; so I am thinking in terms of more intuitive features.
See companion object in scala:
There are connected with class with the same name.
For persistence objects scala use the same stuff as java – jpa hibernate openlink
See Using JPA With Scala