Umbraco 7.4.1 and courier - umbraco7

After upgrading to 7.4.1 I am unable to Courier Media items.
The first error was that there was no column for help text, So I added this to both environments
ALTER TABLE cmsPropertyType ADD helpText NVARCHAR(1000) NULL
and now another exception is being thrown when packaging items.
Please can anyone help
2016-02-23 12:46:34,722 [39] ERROR Umbraco.Courier.Core.TaskManager -
[Thread 51] An error occurred consuming task Umbraco.Courier.Core.Exceptions.PackageException: Unable to load item with id 'Image' from provider 'Media types' --->
Umbraco.Courier.Core.Exceptions.RetrieveException: Error retrieving item [Image] from provider [d8e6ad88-e73a-11df-9492-0800200c9a66]. --->
NHibernate.Exceptions.GenericADOException: could not execute query [ SELECT this.id as id10, this.contenttypeNodeId as contentt210, this.sortorder as sortorder10, this.text as text10, this.parentGroupId as parentGr510_ FROM cmsPropertyTypeGroup this_ WHERE this.contenttypeNodeId = #p0 ] Positional parameters: #0>1032 [SQL: SELECT this.id as id10, this.contenttypeNodeId as contentt210, this.sortorder as sortorder10, this.text as text10, this.parentGroupId as parentGr510 FROM cmsPropertyTypeGroup this_ WHERE this_.contenttypeNodeId = #p0] ---> System.Data.SqlClient.SqlException: Invalid column name 'parentGroupId'.

Related

Spring JPA ObjectOptimisticLockingFailureException and not using batch inserts/update

To give you the context about the issue I am facing, this is a customer table in a Postgres database and its status is update by EventHandler which picks up events from a single SQS queue. This error comes up
ObjectOptimisticLockingFailureException
Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update customer set created_by=?, lock_id=?, modifiedat=?, modified_by=?, app_id=?, client=?, comments=?, customer_id=?, decision=?, source=? where id=? and lock_id=?; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update customer set created_by=?, lock_id=?, modifiedat=?, modified_by=?, application_id=?, client_app=?, comments=?, customer_id=?, decision=?, source=? where id=? and lock_id=?
Now this error shows that batch update is happening but nowhere in this function I am doing batch updates. The code where this insert happens is
public Customer updateOrCreateCustomer(int customerId, String applicationId, String status) {
Customer customer = customerRepository.findByCustomerId(customerId);
if(customer == null) {
customer = new Customer();
customer.setCustomerId(customerId);
customer.setApplicationId(applicationId);
customer.status(status);
log.info("Creating Customer with Customer Id - {} Application Id - {}", customerId, applicationId);
} else {
customer.setStatus(status);
log.info("Updating Customer with Customer Id - {} Application Id - {}", customerId, applicationId);
}
return customerRepository.save(customer);
}
Also, in my application.yml, I have set the batch_size property of JPA to 50 but this is being used in a different API where I need to do batch inserts
jpa:
hibernate:
ddl-auto: none
open-in-view: false
properties:
generate_statistics: false
hibernate:
order_inserts: true
jdbc:
batch_size: 50
I don't know why JPA is doing batch updates in updateOrCreateCustomer function. What I guess is that many requests are coming at the same time so JPA sees that batch_size is set, so it automatically combines all these queries into one to optimize inserts/updates and does that. Please help
I think if your object is modified in another thread, and then you try to commit that same object from another thread at the same time, you maybe get ObjectOptimisticLockingFailureException
The solution I know is to raise the separation level so that the items are commited one by one and there is no synchronization error.
#Transactional(isolation = Isolation.ISOLATION_REPEATABLE_READ)

Insert batch and Return full object using NamedParameterJdbcTemplate

I am trying to do batch insertion to a table and then read full objects back with their newly generated ids.
private List<Customer> saveCustomer(List<Customer> customerList, Long shopId) {
AtomicInteger index = new AtomicInteger();
SqlParameterSource[] paramsArray = new MapSqlParameterSource[customerList.size()];
for (Customer customer : customerList) {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("shop_id", shopId);
params.addValue("customer_name", pallet.getName());
params.addValue("email", pallet.getEmail());
params.addValue("contact_number", pallet.getContactNumber());
paramsArray[index.getAndIncrement()] = params;
}
String sql =
"INSERT INTO \"Customer\" " +
"(shop_id, customer_name, email, contact_number) " +
"VALUES (:shop_id, :customer_name, :email, :contact_number) " +
"RETURNING id, shop_id, customer_name, email, contact_number ";
return namedParameterJdbcTemplate.getJdbcOperations().query(sql, paramsArray, new CustomerRowMapper());
}
However, this method gives me following error: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.springframework.jdbc.core.namedparam.MapSqlParameterSource. Use setObject() with an explicit Types value to specify the type to use. See stack trace below.
PreparedStatementCallback; bad SQL grammar [INSERT INTO "Customer" (shop_id, customer_name, email, contact_number) VALUES (:shop_id, :customer_name, :email, :contact_number) RETURNING id, shop_id, customer_name, email, contact_number ]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.springframework.jdbc.core.namedparam.MapSqlParameterSource. Use setObject() with an explicit Types value to specify the type to use.
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO "Customer" (shop_id, customer_name, email, contact_number) VALUES (:shop_id, :customer_name, :email, :contact_number) RETURNING id, shop_id, customer_name, email, contact_number ]; nested exception is org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.springframework.jdbc.core.namedparam.MapSqlParameterSource. Use setObject() with an explicit Types value to specify the type to use.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:669)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:700)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:712)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:763)
Everything would be fine if I just wanted to do batch insertion without reading it back. Then I would use
namedParameterJdbcTemplate.batchUpdate(sql, paramsArray);
However, I also need to read inserted values back with their ids but not sure what namedParameterJdbcTemplate method I can use.
TLDR:
I want to do batch insertion and then read inserted rows back using namedParameterJdbcTemplate but cannot find the right method for this. Does namedParameterJdbcTemplate provide batch insertion and selection in a single method?
I got something to work.
private List<Customer> saveCustomer(List<Customer> customerList, Long shopId) {
List<Object[]> batch = customers.stream()
.map(customer -> new Object[] {shopId, customer.getName(), customer.getEmail(), customer.getContactNumber()})
.toList();
String sql = "INSERT INTO \"Customer\" " +
"(shop_id, customer_name, email, contact_number) " +
"values :batch" +
"RETURNING id, shop_id, customer_name, email, contact_number ";
return namedParameterJdbcTemplate.query(sql,
new MapSqlParameterSource("batch", batch),
new CustomerRowMapper());
}
Would love to know if there's a better way
Note: each element of each Object[] is a parameter getting passed and there's a hard cap of 65535 parameters which can be passed at once
As I can see from the methods of namedParameterJdbcTemplate you can't execute batch operation and waiting for something back. What you can do is to execute statement in 1 sql request. Just combine your values if your database supports such syntax:
INSERT INTO Customer (shop_id, customer_name, email, contact_number)
VALUES
(value_list_1),
(value_list_2),
...
(value_list_n);
Then just use JDBCTemplate.update with the GeneratedKeyHolder argument. This might help you: identity from sql insert via jdbctemplate

D365 - Get solution list which contains specific string in 'uniquename'

I want to get list of list of solution displayed in DropDown in windows application.
So, to get the list of solutions I have written below QueryExpression and added a filter for the same:
public EntityCollection GetSolutions(IOrganizationService service, string solutionUniqueNameLike)
{
QueryExpression querySampleSolution = new QueryExpression
{
EntityName = "solution",
ColumnSet = new ColumnSet(new string[] { "publisherid", "installedon", "version", "versionnumber", "friendlyname", "ismanaged", "uniquename" }),
Criteria = new FilterExpression()
};
querySampleSolution.Criteria.AddCondition("uniquename".ToLower(), ConditionOperator.Like, "*" + solutionUniqueNameLike.ToLower() + "*");
var solutions = service.RetrieveMultiple(querySampleSolution);
//var filteredSolutions = solutions.Entities.Where(e => (e.Attributes.Contains("uniquename")) && (e.Attributes["uniquename"].ToString().ToLower() == "*" + solutionUniqueNameLike + "*"));
if (solutions?.Entities?.Count > 0)
{
return solutions;
}
return null;
}
But it is returning the 0 entities in the result.
I have also tried to search in the all solutions by using LINQ as added in the commented line of code above. But getting NULL in there.
EDIT 1: When I tried using Contains instead of `Like condition, it is throwing an error as below:
System.ServiceModel.FaultException1 HResult=0x80131501 Message=
Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql
ErrorCode: -2146232060 Sql Number: 7601 Source=mscorlib
StackTrace: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at
Microsoft.Xrm.Sdk.IOrganizationService.RetrieveMultiple(QueryBase
query) at
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultipleCore(QueryBase
query) at
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.RetrieveMultiple(QueryBase
query) at
Microsoft.Xrm.Client.Services.OrganizationService.<>c__DisplayClass22.<RetrieveMultiple>b__21(IOrganizationService
s) at
Microsoft.Xrm.Client.Services.OrganizationService.InnerOrganizationService.UsingService[TResult](Func2
action) at
Microsoft.Xrm.Client.Services.OrganizationService.RetrieveMultiple(QueryBase
query) at TestProjectForCRM.Program.Main(String[] args) in
C:\Users\pratik.soni\source\repos\TestProjectForCRM\TestProjectForCRM\Program.cs:line
37
Not sure what I'm missing here.
I want to add why you are seeing the below error:
System.ServiceModel.FaultException1 HResult=0x80131501 Message=
Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql
ErrorCode: -2146232060 Sql Number: 7601
The piece which will be useful is Sql Number: 7601, the Database engine Events & Errors says Cannot use a CONTAINS or FREETEXT predicate on %S_MSG '%.*ls' because it is not full-text indexed.
Refer my blog on how to crack this error message.

Problem in updating a data column in spring

I have a Database table called ProgramData. their i have a data column called Id and executed. id set to be as auto increment.
Table structure is like this.
What i want is according to id executed column need to be updated. following is my code segment.
public void saveDtvProgDataExecuted()
{
ProgramData programeData = new ProgramData();
String SQL = "UPDATE program_data SET executed=1 WHERE programeData.id = ?";
this.jdbcTemplate.update(SQL);
}
If i run this code this gives me error like bad SQL grammar [UPDATE program_data SET executed=1 WHERE programeData.id = ?]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1
Problem is you’re not passing the ID value to the jdbctemplate.
You should use
this.jdbctemplate.update(SQL, id);
Where id is the id of the record you’re updating.
Please refer to the documentation for more information:
http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#jdbc-updates
TRY THIS statement while you are passing ? in your sql query it need to be set while execution.
String SQL = "UPDATE program_data SET executed=1 WHERE programeData.id = ?";
this.jdbcTemplate.update(SQL,new PreparedStatementCallback<Boolean>(){
#Override
public Boolean doInPreparedStatement(PreparedStatement ps)
throws SQLException, DataAccessException {
ps.setInt(1,"here you need to pass value of programeData.id);
return ps.execute();
}
});

Delete User In MemberShip System

I use three table for a section of my program :
1- aspnet_membership (Fields of table are in asp.net membership )
2-aspnet_user (Fields of table are in asp.net membership )
3-TBL_INFO (Filds : INFO_ID,INFO_USERNAME,INFO_ADDRESS,INFO_TELL)
So,When I want show the required field in Gridview , everything is ok and I don't have any problem .
Store Procedure for SELECT :
CREATE PROCEDURE STR_SELECT_USERS_ADMIN
AS
SELECT aspnet_Users.UserId, aspnet_Users.UserName, aspnet_Membership.CreateDate, TB_INFO.INFO_ADDRESS, TB_INFO.INFO_TELL, aspnet_Membership.Email,
aspnet_Membership.LastLoginDate
FROM aspnet_Membership INNER JOIN
aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId INNER JOIN
TB_INFO ON aspnet_Users.UserName = TB_INFO.INFO_USERNAME
But when i decide to delete a user , I can't :
Stored Procedure for Delete :
ALTER PROCEDURE STR_DELETE_USER
(
#UserId UNIQUEIDENTIFIER
)
AS
DELETE FROM aspnet_Users
WHERE (UserId = #UserId)
and my code in Program for delete in GridView is as Below :
protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
{
string strUserName = GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text;
if (Membership.DeleteUser(strUserName, true) == true)
{
//GridView1.DataBind();
lblResult.Text = "Delete Successfully";
}
else
{
lblResult.Text = "Delete Faild";
}
GridView1.DataBind();
}
and The error when i'm going delete a record create as below :
Server Error in '/' Application.
--------------------------------------------------------------------------------
The parameter 'username' must not be empty.
Parameter name: username
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The parameter 'username' must not be empty.
Parameter name: username
Source Error:
Line 26: string strUserName = GridView1.Rows[GridView1.SelectedIndex].Cells[0].Text;
Line 27:
Line 28: if (Membership.DeleteUser(strUserName, true) == true)
Line 29: {
Line 30: //GridView1.DataBind();
Thank You For Your Time. Thank You So Much

Resources