object-object-mapping

Ajax pass a “Map” object to Spring MVC Controller

我的梦境 提交于 2021-02-19 01:47:30
问题 It seems like Spring MVC doesn't know how to map a javascript "map" to a Java map object In the web UI, say, foo.jsp, <script> var myMap = {}; myMap["people"] = ["Alex","Bob","Charles","Dave"]; myMap["fruit"] = ["Apple","Orange"]; $.ajax({ type : "POST", url : "/myURL", data : "myMap=" + myMap, // I tried "myMap="+JSON.stringify(myMap), as well, it doesn't work neither success : function(response) { alert("Success! response = " + response); }, error : function(e) { alert("AJAX error"); } });

Is there a suggested pattern for using LINQ between the Model & DataAccess Layers in a DDD based Layered Architecture

会有一股神秘感。 提交于 2020-01-22 05:32:25
问题 I've been reading Tim McCarthy's awesome book on DDD in .NET. In his example application though, his underlying data access is using SqlCE and he's handcrafting the SQL inline. I've been playing with some patterns for leveraging Entity Framework but I've gotten stuck on how exactly to map the IRepository linq queries to the underlying data access layer. I have a concrete repository implementation called. public EFCustomerRepository : IRepository<DomainEntities.Customer> { IEnumerable

MapStruct: Object.class to Custom.class mapping

安稳与你 提交于 2019-12-24 12:50:31
问题 I'm a newbie with MapStruct , and need some help with that. I have a Source class, with an attribute Object input; Which, in runtime, returns a custom object named TicketDetails. Now, in my target class there is a attribute named, MyTicket myTicket; which, I need to map with an attribute of TicketDetails object. For, better understanding, I'm writing the normal java code example below. SourceClassModel sourceClassModel = new SourceClassModel(); TargetClassModel targetClassModel = new

ModelMapper: mapping abstract classes during runtime

喜夏-厌秋 提交于 2019-12-19 09:18:25
问题 I am using ModelMapper Framework (http://modelmapper.org/) for mapping objects in Java. I have encountered a problem while mapping concrete classes (DTO to Entites) containing abstract classes. Example: Task has a list of AbstractItems. AbstractItems are Question and Criteria. public class TaskDTO { ... private List<AbstractItemDTO> items; } Mapping method: // task is an TaskDTO object return getModelMapper().map(task, TaskEntity.class); ModelMapper tries to create a new instance of

Automapper - Bestpractice of mapping a many-to-many association into a flat object

早过忘川 提交于 2019-12-18 17:04:12
问题 I have two entities: Employee and Team . What I want is an EmployeeForm that has the Name of the Team . How can I achieve this using AutoMapper ? My current "solution" is the following: Mapper.CreateMap<Employee, EmployeeForm>() .ForMember(dest => dest.TeamName, opt => opt.MapFrom(x => x.GetTeams().FirstOrDefault() != null ? string.Join(", ", x.GetTeams().Select(y=>y.Name)) : "n/a")); In my opinion this is bad readable. What I would like to have is a generic method where I can pass an entity,

Ignore mapping one property with Automapper

我的未来我决定 提交于 2019-12-17 16:43:18
问题 I'm using Automapper and I have the following scenario: Class OrderModel has a property called 'ProductName' that isn't in the database. So when I try to do the mapping with: Mapper.CreateMap<OrderModel, Orders>(); It generates an exception : "The following 1 properties on Project.ViewModels.OrderModel are not mapped: 'ProductName' I've read at AutoMapper's Wiki for Projections the opposite case (the extra attribute is on the destination, not in the source which is actually my case ) How can

Can not deserialize instance of Object out of START_ARRAY token

笑着哭i 提交于 2019-12-12 17:07:50
问题 I have two object one is Dashboard and second is Room i have a json which is look like this { "hotel_id":"1", "hotel_room":"200", "hotel_properties":[{ "id":"1", "room_type":"Single", "rack_rate":"2000", "publish_rate":"1800", "discount":"10", "availiable":"40", "total":"50" }, { "id":"2", "room_type":"Double", "rack_rate":"4000", "publish_rate":"3600", "discount":"10", "availiable":"45", "total":"50" } ] } And the Object is public class DashBoard { private int hotel_id; private int hotel

Can't map property when using MapStruct

折月煮酒 提交于 2019-12-10 16:45:59
问题 I am using MapStruct library to map objects but I got this error: Can't map property "java.util.Date aDate" to "javax.xml.bind.JAXBElement ADATE". Consider to declare/implement a mapping method: "javax.xml.bind.JAXBElement map(java.util.Date value)". My question: WHERE should I decleare this mapping method? 回答1: I solved this issue by writing another class: public class DateMapper { public JAXBElement<XMLGregorianCalendar> map(Date value) { // conversion here return atswer; } } and using this

Restkit to-many relationship append to set instead of setting a new set

半城伤御伤魂 提交于 2019-12-07 06:00:56
问题 I have a iOS Restkit related question. I have a parent-child relationship data coming from a remote server and map those object to a NSManagedObject object with Restkit. The problem that I am currently having is every request to the server always wipe out the "child" relationship and replace it with the new data coming from the server. Is there a way to avoid those and append the new child instead? For example: I have a classic Category --> Products relationship. {"categories": [ { "cat_id":

ECMAScript5 deep copy of object and arrays

可紊 提交于 2019-12-06 07:52:47
问题 I'd hope to find an example code to do a deep copying of objects in ECMAScript5. The copying should be able to clone Nested objects Nested arrays Nested objects in arrays (clone each array item individually) Note: jQuery.extend() does not seem to handle case 3). Also, I'd hope to do this in clean ECMAScript. Quick googling did not bring up any worthy implementations. 回答1: I finally settled to jQuery.extend() as I couldn't find other good implementations http://api.jquery.com/jQuery.extend/