tag:blogger.com,1999:blog-2526628884837213668.post6308676057518082613..comments2024-03-27T00:14:35.505-07:00Comments on Adapting and Learning: Domain-Driven Design: Referencing Aggregates and Using DTOsLorenzo Deehttp://www.blogger.com/profile/00551506284562303520noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-2526628884837213668.post-82586399975556891442021-04-28T19:40:47.237-07:002021-04-28T19:40:47.237-07:00At this point, depending on the complexity of the ...At this point, depending on the complexity of the MEMS component under development, the entire team may consist of at least four people. The main goals of the engineering team during this stage are to develop the technology and stabilize the function of the device. The main goals of the business team during this stage are to secure financing and validate the product and market opportunity. <a href="https://thoughtleadershipzen.blogspot.com/" rel="nofollow">what is thought leadership</a>The DBhttps://www.blogger.com/profile/07938963620314196670noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-69281656433162698992017-02-15T22:43:51.307-08:002017-02-15T22:43:51.307-08:00But with do not work with data (not null) :0(But with do not work with data (not null) :0(stolbovdhttps://www.blogger.com/profile/15384388911954618514noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-26522076024610985572017-02-10T02:41:02.828-08:002017-02-10T02:41:02.828-08:00Lorenzo, thank you. Your code is very useful for m...Lorenzo, thank you. Your code is very useful for me. This works with both the @ManyToOne and the @ManyToMany associations.<br /><br />@ManyToOne(targetEntity = Bird.class)<br />@JoinColumn(name = "ksf_tsb_id")<br />private Long birdId;<br /><br />@ManyToMany(targetEntity = Bird.class)<br />@JoinTable(name = "test_leaf_bird",<br />joinColumns = @JoinColumn(name = "tsd_tsf_id",<br />referencedColumnName = "tsf_id"),<br />inverseJoinColumns = @JoinColumn(name = "tsd_tsb_id",<br />referencedColumnName = "tsb_id"))<br />private List< Long> birdIds;stolbovdhttps://www.blogger.com/profile/15384388911954618514noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-65044267050152065232017-02-10T02:38:34.511-08:002017-02-10T02:38:34.511-08:00This comment has been removed by the author.stolbovdhttps://www.blogger.com/profile/15384388911954618514noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-58820021723279061022016-07-13T22:35:45.212-07:002016-07-13T22:35:45.212-07:00Thanks for asking Albam.
Yes, if I remember corre...Thanks for asking Albam.<br /><br />Yes, if I remember correctly, the JPA mapping shown here only resulted into the desired DDL (with FK constraint). But, after that, the code couldn't be run. So, we had to change it back to reference the entity type.<br /><br />We ended up with a separate DDL with FKs if needed (not auto-generated by JPA), and Java code that referenced by ID (e.g. Long, or ProductId) without JPA relationship mapping.<br /><br />HTH (Hope this helps)Lorenzo Deehttps://www.blogger.com/profile/00551506284562303520noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-46724457204157723402016-04-26T03:14:47.721-07:002016-04-26T03:14:47.721-07:00Lorenzo, I replicate your example, in which you ex...Lorenzo, I replicate your example, in which you explain how to achieve referencing other aggregates only with his id.<br />Although the code has compiled and generates tables correctly, I got the following error when trying to instantiate OrderItem.<br /><br />java.lang.IllegalArgumentException: Can not set java.lang.Long field com.aggregates.model.OrdenItem.ordenId to com.aggregates.model.Orden<br /> at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[na:1.8.0_51]<br /> at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[na:1.8.0_51]<br /> at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[na:1.8.0_51]<br /><br /><br />What I gather is that when instantiating OrdenItem, JPA assumes that the attribute must be the same type of aggregate. I had to remove annotations in OrdenItem<br />@ManyToOne (TargetEntity = Orden.class, optional = false)<br />@ManyToOne (TargetEntity = Product.class, optional = false)<br />to make this work, but I lost some unidirectional foreign key in database.<br /><br />I searched how to implement the recommendations of Vaughn Vernon, even in the code of his book, but his examples do not use the JPA. Practically, The only example that I found was this, other references suggests that JPA can only set these references using the same type of aggregates as attribute.<br /><br />The consultation is implemented with SpringData<br /><br /> @query ( ""<br /> + "SELECT b"<br /> + "FROM OrdenItem b"<br /> )<br /> List findByYYYY ();<br /><br /><br />I use the following technologies.<br /><br />Spring Data<br />Hibernate 4.3.11.Final<br />SQL Server 2012<br />Viva Mileihttps://www.blogger.com/profile/17600850726809846581noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-55807325951022341252016-01-28T23:02:51.802-08:002016-01-28T23:02:51.802-08:00Thanks for pointing that out. I've updated the...Thanks for pointing that out. I've updated the sample. Your suggestion of using a left outer join will work too.Lorenzo Deehttps://www.blogger.com/profile/00551506284562303520noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-68360429655360722882016-01-07T02:56:51.123-08:002016-01-07T02:56:51.123-08:00One comment about OrderAssembler class: for-loop o...One comment about OrderAssembler class: for-loop of OrderItems is N+1 select issue. Consider one query outside for-loop to retrieve all OrderItems using a left outer join.Speedbirdhttps://www.blogger.com/profile/08300448586040498572noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-73866328677859272032014-08-13T02:02:09.917-07:002014-08-13T02:02:09.917-07:00Consider the use of CQRS along with DDD, this way ...Consider the use of CQRS along with DDD, this way you can directly construct the DTO's used in the queries from your persistence storage often your RDBMS. I have written a short post on such a approach here http://noobjuggler.blogspot.in/2011/10/mind-map-for-ddd-cqrs-base-project.htmlAnonymoushttps://www.blogger.com/profile/01437129180441953264noreply@blogger.comtag:blogger.com,1999:blog-2526628884837213668.post-5093415836203423052014-08-13T01:27:38.322-07:002014-08-13T01:27:38.322-07:00Your post are brilliant, I would imagine that you ...Your post are brilliant, I would imagine that you should figure much higher up in the search results :) I enjoyed reading your DDD post !! ThanksAnonymoushttps://www.blogger.com/profile/01437129180441953264noreply@blogger.com