(N) Hibernate: display core / main with relationships

I am starting at a mid-sized company that mainly works on writing custom applications that interact with their ERP system. This is my first experience of this kind of work, so the ERP concept is new to me, and I am exploring its piece of food.

I've only written two applications so far and learned the database model as I went, and only as much as I need to get the job done, but even with this limited amount, I can start to see the big picture. My idea was to write a library with all the mapping / model objects stored there so that the new application can just reference that library. After that, each application will create its own repository, limiting access to only what they need and a perspective that makes sense.

The challenge / question I have is how to deal with relationships inside (N) sleeping mappings. If I have an order object with complete relationships mapped in this underlying library, there is nothing to prevent someone from traveling to that relationship forever (if I were the only programmer ...). So using a repository as a kind of volume limitation doesn't work at all in this sense.

If I instead restrict the relationship in the (N) Hibernate mapping for that order object, the repository returns the order object associated with only the relationships it requires for its scope. The downside is that now I need to create mappings for each project instead of one "mapping store".

How do other people deal with it?

Kind of unrelated, but I've also translated hibernation (N) objects (H), which can be multiple relationships, into a single one-way object, more suitable for a particular application (usually much more UI-influenced). Is this common, or have I picked some of the benefits of (N) Hibernate by taking the returned objects and translating them into something else?

ps. About the DDD tag ... I don't know if this is what DDD addresses are detailed, but I have a book to order. I'm not sure about a good resource to look at before the book arrives.

0


source to share


1 answer


Quite an old question. I think you already found the answer, but in case ...

I see two ways to solve your problem.



  • Restrict access to the table through the user account in the database. For example, in mysql, you can do this. The downside is that if all of your domain classes are mapped and compiled in your nll-dll, the programmer can still see these objects. If he / she tries to access it, it raises an exception (nh tries to access the database table, database crash).

  • Create a dll for each case. But I think you will have to create multiple accounts as well.

+1


source







All Articles