Marco Rosetti 8 Years Ago Nice post! Very interesting!Thanks for sharing Please sign in to reply. Reply as... Cancel
Olaf Kock 8 Years Ago I like the fake entity with the fake datasource - I've been using empty entities, but this means that model beans have to be totally hand-written, adding more work. This is a good alternative. Thanks for the pointer Please sign in to reply. Reply as... Cancel David H Nebinger Olaf Kock 8 Years Ago Empty entities are great for layering in business logic, but you're stuck using primitives, their Object counterparts, Collections or Entities.The Fake Entity lets you add your own custom classes that are not database-dependent. Please sign in to reply. Reply as... Cancel
David H Nebinger Olaf Kock 8 Years Ago Empty entities are great for layering in business logic, but you're stuck using primitives, their Object counterparts, Collections or Entities.The Fake Entity lets you add your own custom classes that are not database-dependent. Please sign in to reply. Reply as... Cancel
Jack Bakker 8 Years Ago using SB for servicing requests to more than that involving sql tables Please sign in to reply. Reply as... Cancel
Daniele Baggio 8 Years Ago Good post, it's time to use this useful thinks. Please sign in to reply. Reply as... Cancel
Prakash Khanchandani 8 Years Ago Loved it! Thank you for collating and adding your own expertise .. all at one place.can't get easier than this.Thank you Please sign in to reply. Reply as... Cancel
Prakash Khanchandani 8 Years Ago Should be a wiki or tutorial in dev.liferay.com :-) Please sign in to reply. Reply as... Cancel
Philip Teagle 8 Years Ago Not sure if this applies to the use case in which you need to add a Service layer using Service Builder around an existing DB used by a group of Liferay portlets. I have been waiting for someone to crack the reverse engineer a DB into a service.xml, similar to Dali tools reverse engineering a JPA persistence.xml from database tables. Please sign in to reply. Reply as... Cancel
Tahir Noor Khaliq 8 Years Ago can v use composition in fake entity Please sign in to reply. Reply as... Cancel David H Nebinger Tahir Noor Khaliq 8 Years Ago There's no magic to fake entities. They have the same features and constraints as regular entities. Contained collections within an entity typically give SB problems because there's no easy way to manage crossing the class loader boundary with those, so you'll frequently get the operation not supported exception. Please sign in to reply. Reply as... Cancel
David H Nebinger Tahir Noor Khaliq 8 Years Ago There's no magic to fake entities. They have the same features and constraints as regular entities. Contained collections within an entity typically give SB problems because there's no easy way to manage crossing the class loader boundary with those, so you'll frequently get the operation not supported exception. Please sign in to reply. Reply as... Cancel
Vicente Soriano 8 Years Ago Thank you, David, for this entry blog. I've implemented two Fake Entities with 6.2 EE using the persistence layer for caching purposes, and they're working perfectly.As you said, I needed to implement the "NullDataSource" fix you talked about. Please sign in to reply. Reply as... Cancel
amir keshavarz 7 Years Ago Brilliant. Thanks David.Can you please describe more how we can code NullDataSource. Please sign in to reply. Reply as... Cancel David H Nebinger amir keshavarz 7 Years Ago class NullDataSource implements DataSource {}, then you'll have to implement a slew of methods from the interface, any time they return something just return null. I didn't include it in the code because it actually is just that easy. Please sign in to reply. Reply as... Cancel amir keshavarz David H Nebinger 7 Years Ago Thank you so much David. It works very well. Please sign in to reply. Reply as... Cancel
David H Nebinger amir keshavarz 7 Years Ago class NullDataSource implements DataSource {}, then you'll have to implement a slew of methods from the interface, any time they return something just return null. I didn't include it in the code because it actually is just that easy. Please sign in to reply. Reply as... Cancel amir keshavarz David H Nebinger 7 Years Ago Thank you so much David. It works very well. Please sign in to reply. Reply as... Cancel
amir keshavarz David H Nebinger 7 Years Ago Thank you so much David. It works very well. Please sign in to reply. Reply as... Cancel
(You) 6 Years Ago [...] Olaf Kock: The fake entity concept means that you're building an empty entity, with no properties. This will not create a table in the database, just make the service available. No, the "fake... [...] Read More Please sign in to reply. Reply as... Cancel
Kalai Arasan 4 Years Ago Can we follow the same in Liferay 7. when I am trying to create fake service in LR7 it's throwing Null pointer exception while accessing the service from portlet. Please sign in to reply. Reply as... Cancel Olaf Kock Kalai Arasan 4 Years Ago David covered this in the latest Radio Liferay Episode 62 http://radioliferay.com/episode/62 . In short: A classic OSGi Declarative service suffices if you don't need any entity or other ServiceBuilder related handling. Please sign in to reply. Reply as... Cancel Kalai Arasan Olaf Kock 4 Years Ago Hi Olaf, Thankyou for your updates. I need to create a finder with custom sql joins, that's the reason looking for fake service builder. Can we implement multiple sql joins with OSGI declarative services? Please sign in to reply. Reply as... Cancel David H Nebinger Kalai Arasan 4 Years Ago That doesn't call for a fake entity. If you are returning the entity or a list of the entity, you can build custom SQL or a DQ to handle the join and Hibernate/SB will handle the rest of the marshaling effort. Please sign in to reply. Reply as... Cancel Kalai Arasan David H Nebinger 4 Years Ago Thankyou David! I followed this documentation https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL#step-1-specify-your-custom-sql to build custom SQL and it's working fine, only the table is already exist. But actually we don't have any custom table created in our application. We need to join JournalArticle, AssetEntry, AssetCategories and AssetEntries_Assetcategories tables to make a join SQL. I am looking forward to make custom SQL without creating table in database. Please sign in to reply. Reply as... Cancel Ario Bimo Kalai Arasan 3 Years Ago - Edited Hi, Kalai Arasan! What you mean is you want to throw variable with different entity like in spring boot using nativeQuery, right? For this, you can refer to this article: http://liferayiseasy3.blogspot.com/2015/02/custom-sql-with-two-table_17.html But, if you refer to that articel, you cannot load parameter via api/jsonws (you should load data directly using ajax). because you throw object entity that never declare. I often use create view either via database or table.sql (via liferay) and call them by creating new serviceBuilder and connect the view by connecting to external dataSource (to connect to external dataSource, you can refer to https://help.liferay.com/hc/en-us/articles/360018160911-Connecting-Service-Builder-to-External-Data-Sources). I don't know if it is the best way or not but it works very well for me. Hope it may helps :) Please sign in to reply. Reply as... Cancel
Olaf Kock Kalai Arasan 4 Years Ago David covered this in the latest Radio Liferay Episode 62 http://radioliferay.com/episode/62 . In short: A classic OSGi Declarative service suffices if you don't need any entity or other ServiceBuilder related handling. Please sign in to reply. Reply as... Cancel Kalai Arasan Olaf Kock 4 Years Ago Hi Olaf, Thankyou for your updates. I need to create a finder with custom sql joins, that's the reason looking for fake service builder. Can we implement multiple sql joins with OSGI declarative services? Please sign in to reply. Reply as... Cancel David H Nebinger Kalai Arasan 4 Years Ago That doesn't call for a fake entity. If you are returning the entity or a list of the entity, you can build custom SQL or a DQ to handle the join and Hibernate/SB will handle the rest of the marshaling effort. Please sign in to reply. Reply as... Cancel Kalai Arasan David H Nebinger 4 Years Ago Thankyou David! I followed this documentation https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL#step-1-specify-your-custom-sql to build custom SQL and it's working fine, only the table is already exist. But actually we don't have any custom table created in our application. We need to join JournalArticle, AssetEntry, AssetCategories and AssetEntries_Assetcategories tables to make a join SQL. I am looking forward to make custom SQL without creating table in database. Please sign in to reply. Reply as... Cancel Ario Bimo Kalai Arasan 3 Years Ago - Edited Hi, Kalai Arasan! What you mean is you want to throw variable with different entity like in spring boot using nativeQuery, right? For this, you can refer to this article: http://liferayiseasy3.blogspot.com/2015/02/custom-sql-with-two-table_17.html But, if you refer to that articel, you cannot load parameter via api/jsonws (you should load data directly using ajax). because you throw object entity that never declare. I often use create view either via database or table.sql (via liferay) and call them by creating new serviceBuilder and connect the view by connecting to external dataSource (to connect to external dataSource, you can refer to https://help.liferay.com/hc/en-us/articles/360018160911-Connecting-Service-Builder-to-External-Data-Sources). I don't know if it is the best way or not but it works very well for me. Hope it may helps :) Please sign in to reply. Reply as... Cancel
Kalai Arasan Olaf Kock 4 Years Ago Hi Olaf, Thankyou for your updates. I need to create a finder with custom sql joins, that's the reason looking for fake service builder. Can we implement multiple sql joins with OSGI declarative services? Please sign in to reply. Reply as... Cancel David H Nebinger Kalai Arasan 4 Years Ago That doesn't call for a fake entity. If you are returning the entity or a list of the entity, you can build custom SQL or a DQ to handle the join and Hibernate/SB will handle the rest of the marshaling effort. Please sign in to reply. Reply as... Cancel Kalai Arasan David H Nebinger 4 Years Ago Thankyou David! I followed this documentation https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL#step-1-specify-your-custom-sql to build custom SQL and it's working fine, only the table is already exist. But actually we don't have any custom table created in our application. We need to join JournalArticle, AssetEntry, AssetCategories and AssetEntries_Assetcategories tables to make a join SQL. I am looking forward to make custom SQL without creating table in database. Please sign in to reply. Reply as... Cancel Ario Bimo Kalai Arasan 3 Years Ago - Edited Hi, Kalai Arasan! What you mean is you want to throw variable with different entity like in spring boot using nativeQuery, right? For this, you can refer to this article: http://liferayiseasy3.blogspot.com/2015/02/custom-sql-with-two-table_17.html But, if you refer to that articel, you cannot load parameter via api/jsonws (you should load data directly using ajax). because you throw object entity that never declare. I often use create view either via database or table.sql (via liferay) and call them by creating new serviceBuilder and connect the view by connecting to external dataSource (to connect to external dataSource, you can refer to https://help.liferay.com/hc/en-us/articles/360018160911-Connecting-Service-Builder-to-External-Data-Sources). I don't know if it is the best way or not but it works very well for me. Hope it may helps :) Please sign in to reply. Reply as... Cancel
David H Nebinger Kalai Arasan 4 Years Ago That doesn't call for a fake entity. If you are returning the entity or a list of the entity, you can build custom SQL or a DQ to handle the join and Hibernate/SB will handle the rest of the marshaling effort. Please sign in to reply. Reply as... Cancel Kalai Arasan David H Nebinger 4 Years Ago Thankyou David! I followed this documentation https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL#step-1-specify-your-custom-sql to build custom SQL and it's working fine, only the table is already exist. But actually we don't have any custom table created in our application. We need to join JournalArticle, AssetEntry, AssetCategories and AssetEntries_Assetcategories tables to make a join SQL. I am looking forward to make custom SQL without creating table in database. Please sign in to reply. Reply as... Cancel Ario Bimo Kalai Arasan 3 Years Ago - Edited Hi, Kalai Arasan! What you mean is you want to throw variable with different entity like in spring boot using nativeQuery, right? For this, you can refer to this article: http://liferayiseasy3.blogspot.com/2015/02/custom-sql-with-two-table_17.html But, if you refer to that articel, you cannot load parameter via api/jsonws (you should load data directly using ajax). because you throw object entity that never declare. I often use create view either via database or table.sql (via liferay) and call them by creating new serviceBuilder and connect the view by connecting to external dataSource (to connect to external dataSource, you can refer to https://help.liferay.com/hc/en-us/articles/360018160911-Connecting-Service-Builder-to-External-Data-Sources). I don't know if it is the best way or not but it works very well for me. Hope it may helps :) Please sign in to reply. Reply as... Cancel
Kalai Arasan David H Nebinger 4 Years Ago Thankyou David! I followed this documentation https://help.liferay.com/hc/en-us/articles/360017882012-Custom-SQL#step-1-specify-your-custom-sql to build custom SQL and it's working fine, only the table is already exist. But actually we don't have any custom table created in our application. We need to join JournalArticle, AssetEntry, AssetCategories and AssetEntries_Assetcategories tables to make a join SQL. I am looking forward to make custom SQL without creating table in database. Please sign in to reply. Reply as... Cancel Ario Bimo Kalai Arasan 3 Years Ago - Edited Hi, Kalai Arasan! What you mean is you want to throw variable with different entity like in spring boot using nativeQuery, right? For this, you can refer to this article: http://liferayiseasy3.blogspot.com/2015/02/custom-sql-with-two-table_17.html But, if you refer to that articel, you cannot load parameter via api/jsonws (you should load data directly using ajax). because you throw object entity that never declare. I often use create view either via database or table.sql (via liferay) and call them by creating new serviceBuilder and connect the view by connecting to external dataSource (to connect to external dataSource, you can refer to https://help.liferay.com/hc/en-us/articles/360018160911-Connecting-Service-Builder-to-External-Data-Sources). I don't know if it is the best way or not but it works very well for me. Hope it may helps :) Please sign in to reply. Reply as... Cancel
Ario Bimo Kalai Arasan 3 Years Ago - Edited Hi, Kalai Arasan! What you mean is you want to throw variable with different entity like in spring boot using nativeQuery, right? For this, you can refer to this article: http://liferayiseasy3.blogspot.com/2015/02/custom-sql-with-two-table_17.html But, if you refer to that articel, you cannot load parameter via api/jsonws (you should load data directly using ajax). because you throw object entity that never declare. I often use create view either via database or table.sql (via liferay) and call them by creating new serviceBuilder and connect the view by connecting to external dataSource (to connect to external dataSource, you can refer to https://help.liferay.com/hc/en-us/articles/360018160911-Connecting-Service-Builder-to-External-Data-Sources). I don't know if it is the best way or not but it works very well for me. Hope it may helps :) Please sign in to reply. Reply as... Cancel