Passing a Object to sql server Stored Procedure (as TVP) - object

I have scenario , where I pass the entity (Object) with other dependent child entity to the Stored procedure and the SP should create/delete/update the tables respective for that entity in the Database.
Eg -
Entity - Person
ChildEntity - Skills, JobDetails.
so i will just pass the Person object which includes all the other object collection and the stored procedure will acccept that parameter and do the respecitve CRUD operation.
Is there any option where i can pass the whole object to DB and then play with the object in the DB.(I donot want to go with the XML approach also would like to pass the whole object instead of divinding the object into single entities)
Need your suggestions, Thanx.
Kind Regards

Related

how to defined and object collections in Jhipster?

How would you do this? Let's say you have a FrontPage object that is a collection of Many Post object. But it is not any kind of collection. It is a collection made of known members: 5 latest news (LatestNews#1, LatestNews#2, ... LatestNews#5) 5 popular news, and more, up to 25 individual Post Objects.
You can have a FrontPageObject like this....
entity FrontPageConfig {
creationDate Instant required
latestNews1 Long
latestNews2 Long
latestNews3 Long
latestNews4 Long
latestNews5 Long
topNews1 Long
and so on....}
entity Post {
body TextBlob minbytes(3) maxbytes(50000) required
}
... where the Long attribute represents the id of the Post object.
But when you do it, you have to load the object in Angular and make 25 calls to the the server to call the Posts.
How can I have an FrontPageConfig object that has all the properties as defined (latestNews1) Post objects inside and that I only have to call once.
Thanks again.
PD: I tried with OneToOne relationships:
FrontPageConfig{topNews1(id)} to Post{topNews1(id)}
And OneToMany or ManyToOne:
FrontPageConfig{topNews1(id)} to Post{topNews1(id)}
But it is not a defined collection!
And this relationship OneToMany {
Post{topNews1} to FrontPageConfig{topNews1}
Does not give the object, only the id!
This is a good use case for Data Transfer Objects (DTOs).
Create a custom API endpoint and in that method, query the database.
Create a custom DTO object (such as FrontPageDTO) with the fields you want to return to the user interface.
In your service class (or resource if you don't use services), make the queries through the repository to get the information you need.
Query for 5 latest news and 5 top news, then map that data to the DTO fields
Return the DTO once the fields are set

Giving your own ids to Core Data objects

I have some points on a map with associated informations contained by Core Data, to link the points on the map with the associated info, I would like to have an ID for each point, so in my entity, I would need some ID property, I have read that Core Data has it's own IDs for every managed object but I'm wondering wether or not it would be a good approach for me to directly use them or if I should create my own ID system ?
If you think I should create my OWN ID system, how would I do that ?
Thank you.
CoreData is not an relational database and you should avoid thinking about own ID’s. You may need them only for syncing purposes with external databases. For more precise answer, you should write how your model looks.
[edited after comment]
I don't see that you need any relations. Let's sat you have MapPoint entity with lat, and long properties. If there is only one user note, you just add another property to it like notes. If you have many informations (many records) stored with one MapPoint you need to add Notes entity with properties note and mappoint and make a relation between them. When you insert new Notes object into CoreData you set mappoint property to already existing MapPoint object (fetched after user tap).

How do you pass a NotesDocument / NotesViewEntry Collection into a Custom Control via custom property?

I want to have a custom control that works on whatever documents I decide to pass to it. What's the best way of doing that?
Assuming that you can't pass the collection directly... should a function be created to convert the collection to a hashMap or vector of UNID's?
Is there another way?
Thanks
If you instead pass a data source, you'll get recycle-safe objects transferred to the Custom Control.
For example, if the XPage defines a document data source, and you pass a reference to that data source to the CC, the Java object being transferred is a DominoDocument, which is a recycle-safe wrapper around the "back end" document. Passing the document directly risks that the linked C object will get orphaned between requests.
Similarly, passing a reference to a view data source provides the CC a DominoView, which is essentially a recycle-safe wrapper around a back end ViewEntryCollection.
For most use cases, you can get away with just passing the back end object directly, but passing the data source is far safer.
Passing NotesDocument and/or NotesDocumentCollection objects to the Custom Control works fine. Just set the Custom Control's property type as java.lang.Object. By this you can transfer what ever objects to the Custom Control.

Core Data: Design questions. Object wrappers or not?

I'm designing my first project using Core Data (for iPhone) and Im having some issues that might be related with my design approach.
I'm doing an application that allows the user to create an Order (let's say for a restaurant).
I'm using the graphic designer to model my persistence object (i.e. OrdeMO). I add MO to the ead of each name to indicate its a Managed Object.
I use XCode to create the Managed Object Class automatically.
I have created some "DAO" classes that allows you to search or create a new object in the Managed Context.
Now to my problem.
I want to create an OrderMO object to store the order the user is creating, BUT I don't want it to be part of the context until the user actually places it.
I tried creating the object with [OrderMO alloc] but the object I get is "incomplete" and when I try to set any of its attribute I get an error.
I'm assuming the problem is that I need to create the order IN the context in order to use it. Is that so?
I have considered various options:
Create the object in the context and the user rollback if the user discards the order. The problem is that the user might save other context object during the process (like his prefs) so this doesn't work. Is there a way to create the object "inside a separate transaction" of sorts?
Create a wrapper object that will hold the same data as the MO, and then only create the MO when the user place the order. The downside of this is that I have to maintain a new class.
Create an attribute in the MO, such as "placed", and use to filter my searches in the context. The problem with this one is that I will end up with "trash" objects in the domain (i.e. unplaced orders) and I will have to do some cleanup from time to time...
Do I have any other choice?
Any suggestion is appreciated.
Thanks (for reading this long post!)
Gonso
You should create the OrderMO object in the managed object context and then delete it if the user decides not to place the order.
If the context is saved before the object is deleted, the "trash" object will be deleted from the persistent store on the next save (if the context wasn't saved, the "trash" object will never be saved to the persistent store).
The flag to determine if the order was placed or not does not have to live in the OrderMO object as you suggest in option 3. It could be in the view controller that is tracking the order(s) that are being edited. And, again, you won't have "trash" objects because they will have been deleted.

Accessing Aggregate Entities without Lazy Loading

I want to follow the DDD philosophy and not access entity objects of an aggregate directly. So, i have to call the root object to get the associated entity. But In other cases I dont always want every associated entity to load when the root is called. Is that the purpose of lazy loading?
How do I access entity objects through the root without loading all the associated objects everytime if i disable lazyloading feature of linq?
EDIT:
For example, If I have a Person as the Root Entity, and the Person has Name, Addresses and OwnedProperties. If I want to get a list of People so that I could display their names, I dont necvessarily want to load up Owned Properties every time on the call to the Repository. Conversely, on another page I may want to show a list of OwnedProperties, but do not want the other information to load with the call. what is the simple way of just calling the Person without the owned property entity other than creating a new person object without that owned properties?
I don't thinks that's possible without lazy loading.
Getting all data at once: Eager Loading
Getting data when accessed: Lazy Loading
According to your edit:
What I do in these situations, is create a 'View' class or a 'DTO' class which just contains the properties that I'm interested in.
For instance, I could have a 'PersonView' class which just has a Name property for instance.
Then, using my OR/M mapper (I use NHibernate), I create a HQL query (or Criteria query) which works on my 'Person' entity. Before I execute the query, I tell NHibernate that I want 'PersonView' objects as a result (I specify a projection). Then, NHibernate is smart enough to execute a query that only retrieves the columns that are necessary to populate the PersonView instances.
One way to avoid lazy loading is just using the object 'id'

Resources