w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Mongodb change field type
Basicly you cannot do it. While you cannot reference back a value inside a query you cannot convert it on the fly. You can update with a certain value if you know what you likely to put in. There is no such thing: db.collection.update({},{$set:{b:ISODate('$b')}}) This is a current enhancement request. The only way is to write a script which crawl through the collection save docs with the updated type . You also can run query based on the type of a field which may help if your flow brakes in between. For this solution check that question : MongoDB: How to change the type of a field? The solution there is something like : db.collection.find().forEach( function (x) { x.b = new ISODate(x.b); // convert field to ISODate db.collection.save(x); });

Categories : C#

Can I change the Type discriminator property in MongoDB?
I believe you can can create a custom discriminator convention and you can add it to each type you wish to modify; http://docs.mongodb.org/ecosystem/tutorial/serialize-documents-with-the-csharp-driver/#polymorphic-classes-and-discriminators Here's an example of a custom discriminator convention which might help you; http://pastebin.com/9UweEKBe

Categories : C#

Ensuring data persistence in MongoDB
Short answer: you can't. Long answer: Consider using multiple data storage options. Far too often people are jumping on the NoSQL bandwagon, when it isn't necessary. If you need guranteed writes you should use a relational database, or consider a hybrid such as orientDB. Lack of guaranteed writes is one of the big reasons why solutions such as MongoDB scale so well.

Categories : Mongodb

MongoDB - How do I change the type of an string found in an array nested within a subdocument
Your code is assuming that the find returns the embedded assignment objects rather than the object. Change : obj.as_total_hours = parseInt(obj.as_total_hours); db.providers.save(obj); to obj.assignments.assignment.forEach(function(obj) { obj.as_total_hours = parseInt(obj.as_total_hours); }) db.providers.save(obj); You could also change the {$exists:true} to {$type: 2} (or combine them) so that the query only finds strings.

Categories : Mongodb

persistence.xml different transaction-type attributes
Defaults Default to JTA in a JavaEE environment and to RESOURCE_LOCAL in a JavaSE environment. RESOURCE_LOCAL With <persistence-unit transaction-type="RESOURCE_LOCAL"> you are responsible for EntityManager (PersistenceContext/Cache) creating and tracking You must use the EntityManagerFactory to get an EntityManager The resulting EntityManager instance is a PersistenceContext/Cache An EntityManagerFactory can be injected via the @PersistenceUnit annotation only (not @PersistenceContext) You are not allowed to use @PersistenceContext to refer to a unit of type RESOURCE_LOCAL You must use the EntityTransaction API to begin/commit around every call to your EntityManger Calling entityManagerFactory.createEntityManager() twice results in two separate EntityManager instances and theref

Categories : Java

build a org.eclipse.persistence.queries.ReportQuery from a javax.persistence.Query
How are you executing the ReportQuery? You need to call Session.executeQuery(query, arguments) and pass a List of the arguments (order the same as query.getArguments(). You can probably also use the JpaEntityManager createQuery(DatabaseQuery) API to convert the ReportQuery back to a JPA Query, then you can just set the parameter the JPA way.

Categories : Java

NullPointerException: Unable to create the container entity manager factory for the org.jbpm.persistence.jpa persistence unit
I was able to fix this error by setting hibernate.temp.use_jdbc_metadata_defaults to false. I'm not sure from the excerpts you posted where you would set it. For me it was the Spring config of the persistence unit.

Categories : Xml

Error creating bean with name 'entityManagerFactory' -> Cannot parse persistence unit from class path resource [META-INF/persistence.xml]
Firstly, java compiler will not validate the existence of persistence.xml during compile time. The error only happen at runtime. Stack trace you're getting is pretty clear, your program could not locate persistence.xml on classpath. The location of persistence.xml within your jar has to be: META-INF/persistence.xml, or if it's war: WEB-INF/classes/META-INF/persistence.xml

Categories : Java

Entity Framework 5 table-per-type update, change sub type but keep same base type
I don't have a good answer, but I can think of four "solutions" that are really workarounds: Don't use DBMS-computed values for your primary keys (if you already use natural keys, it's fine). Use DBMS-computed surrogate keys. Follow something like the state pattern. Do some evil voodoo with the object state manager. Update: There seems to be a popular consensus that trying isn't even worth it; most people thus simply use stored procedures instead to work around the problem. Changing Inherited Types in Entity Framework Entity Framework: Inheritance, change object type Changing the type of an (Entity Framework) entity that is part of an inheritance hierarchy Changing the type of an entity that is part of an inheritance hierarchy Using natural keys First, remember that the objects tr

Categories : Entity Framework

After JPA Reverse Engineer - No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0
You are missing declaration of mona-contenxt.xml in web.xml and instead declared mona-mvc.xml twice. The change can be something like this: <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:mona-context.xml</param-value> </context-param>

Categories : Java

getting error No qualifying bean of type [javax.persistence.EntityManagerFactory] is defined: expected single matching bean but found 2
I had the same issue today. Solved it doing the following: First I've added the parameter unitName to @PersistenceContext to both entity manager properties: @PersistenceContext(unitName="appPU") @Qualifier(value = "appEntityManagerFactory") private EntityManager appEntityManager; @PersistenceContext(unitName="managerPU") @Qualifier(value = "managerEntityManagerFactory") private EntityManager managerEntityManager; And in my configuration file I've added a property persistenceUnitName to my bean definitions: <bean id="appEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="dataSource1" /> <property name="persistenceUnitName" value="appPU" /> <property name="packagesToScan" val

Categories : Spring

Mongodb update type of field
You can use this command from mongo command line: db.MYCOLLECTION.find({ id_group: { $type: 2 } }).forEach(function(obj){ try { obj.id_group = parseInt(obj.id_group); db.MYCOLLECTION.save(obj); } catch(e) { // do something with error... } }); the id_group: { $type: 2 } tells mongo to load all the id_group which their value is a string. You can find more about mongo types here: http://docs.mongodb.org/manual/reference/operator/type/#op._S_type

Categories : Mongodb

MongoDB type inference using _class
Make sure you map all types you mentioned to be stored in the same collection (e.g. using the @Document annotation). Then you can simply execute queries against the collection handing in Animal to the according method on MongoTemplate. The underlying converter will then automatically instantiate the correct types based on the information stored in _class. The same applies to the usage of Spring Data MongoDB repositories.

Categories : Spring

Use a custom ID type in mongodb usyng python
Do not use dict for _id field, use a hash of that dictionary. Eg. sha1 of the json representation of the dictionary , or just hash if number of records are not that much.

Categories : Python

Not an managed type for Spring Data Mongodb
In the same project we were also using mysql and it was scanning the package: com.example.repositories. This caused the issue and once we changed it to com.example.repositories.mysql it was solved.

Categories : Spring

How to update a generic type with MongoDB C# driver
Assuming that you want to update (replace) the entire object, do this: void Update(T entity) { collection.Save<T>(entity); } It will detect if the _id field is set and save the correct item. If your object includes a primary key property (it should), you can decorate it with the attribute to give Mongo a hint [BsonId()] If you are looking at only updating certain fields, then you could always use reflection to loop through the properties of the type and add them to the Update's setters.

Categories : C#

Mongodb: Specify field data type, collection _id to be datetime
You can't. MongoDB is a schemaless and heterogeneous database. Any field of a document (including _id) can be of any type. There is no way to enforce type constraints on the database level.

Categories : Javascript

Why does a session parameter with type ObjectID (MongoDB) transform to a string?
MongoStore converts the session data to JSON by default based on the "stringify" option. Here's a link to the relevant source code. JSON only supports basic JavaScript data types (String, Number, boolean, etc), not custom object types such as ObjectId. To change this, pass stringify: false in your options when instantiating your MongoStore. Update for follow-ups in comments is there any downside to setting stringify: false? So keep in mind that JSON supports a rich enough set of data types for most applications. The up side of JSON is it keeps your code portable to other session storage options, whereas relying on a full ObjectId instance vs a string will couple your code to mongodb without much benefit. JSON portable neither JSON nor MongoDB are going to give you domain objects

Categories : Javascript

Assertion: 13111:wrong type for field 3 != 4 - MongoDB C++ driver
I can help you with more info about the error: http://docs.mongodb.org/manual/reference/operator/type/#op._S_type 3 => Object 4 => Array

Categories : C++

Change input type="text" to input type="password" onfocus()
You dont need to replace the component, just set the type of the this to password like the code below: <asp:TextBox ID="txtPassword" runat="server" SkinID="txtLogin" value="Password..." TabIndex="2" onfocus="this.type='password'"> Here is a jsfiddle working example: http://jsfiddle.net/mZyTG/ Update I didn't test this code, but it add one onblur event listener to newO, and when invoked it replace the input to the old one. function replaceT(obj) { var newO = document.createElement('input'); newO.setAttribute('type', 'password'); newO.setAttribute('class', 'textbox'); newO.setAttribute('name', obj.getAttribute('name')); newO.addEventListener("onblur", function(){newO.parentNode.replaceChild(obj, newO)}, false); obj.parentNode.replac

Categories : Javascript

html5 media tag change with change of media type in playlist
To use both video and audio in a playlist you should use the html5 video tag instead of the audio tag. You do not need to switch back and forth. The video tag will play both audio and video files. In order to use the code from the site listed, you will need to know whether you are loading a video or an audio file. Then you can determine the correct extension to use based on browser support found in the script. See the new html5 video and audio playlist example below: http://jonhall.info/examples/html5_video_audio_playlist_example.html In the new example I replaced the code: extension = audio.canPlayType('audio/mpeg') ? '.mp3' : audio.canPlayType('audio/ogg') ? '.ogg' : ''; with a function: getExtension = function(type) { extension = ''; if(type === 'a') { if(video.ca

Categories : HTML

MongoDB String type field search match against Array of string
While the $all can only be applied to arrays, this is not the case for $in. What might be causing your problem is that the first query will only match the text exactly, have you tried something like: Tweet.where({:text=>{ "$in" => [/champ/,/looser/]},:load_date.gte=>1.month.ago.utc})

Categories : Ruby On Rails

Convert a ISODate string to mongoDB native ISODate data type
It depends on with what language/driver/utility you're pushing the log. I am assuming you're using mongoimport. mongoimport doesn't support ISODate(). Refer to this issue https://jira.mongodb.org/browse/SERVER-5543 ISODate() is not a JSON format, hence not supported in mongoimport. i) approach seems more efficient. ii) does two actions on mongo: insert & update. I had same issue while importing some log data into mongo. I ended up converting ISO 8601 format date to epoch format. {"LogLevel":"error","Datetime":{"$date" : 1371813617000},"Module":"DB","Method":"ExecuteSelect","Request":"WS_VALIDATE","Error":"Procedure or function 'WS_VALIDATE' expects parameter '@LOGIN_ID', which was not supplied."} Above JSON should work. Note that it is 64-bit not 32-bit epoch.

Categories : Mongodb

How to change the Type of Files
Changing the extension manually won't resolve your problem. That is .class file,containing a Java bytecode which can be executed on jvm,hich humans can't read it. Just decompile it.Use some decompiler.

Categories : Java

Change data type dynamically in c#
In the example you show, it would be simpler to just say: Userid = new System.Guid(value); since the constructor of a Guid takes a string to create the object. That is, unless you're trying to do something else, in which case please clarify your question!

Categories : C#

How can i change mime type for reportviewer?
For Excel 2007 and above the MIME type differs Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AppendHeader("content-disposition", "attachment; filename=" + filename); Reference : Content Type for xlsx Also, What is correct content-type for excel files?

Categories : C#

How to change the instance type in amazon ec2
For whatever reason, Amazon's HVM based AMI is not compatible with the t1.micro size. Amazon has hardware virtual machine (HVM) based AMIs, and paravirtual machine (PVM) based AMIs. From that error message, AWS is saying that your current instance is HVM based, and t1.micro size will only support PVM based instances. The way round this would be to create a new AMI from your instance and launch a new instance from that AMI as t1.micro size. Be careful, though, this may just create an HVM-based AMI, in which case you will need to snapshot the volume for your current instance and create a new AMI from that. Some more information on HVM: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cluster_computing.html#concepts_cluster_compute_hvmAMI http://aws.amazon.com/ec2/faqs/#Does_use_of

Categories : Amazon

How to change data type in SQL Server?
Just turn this option in SQL Server Management Studio off: Menu > Tools > Options This option is on by default (for safety reasons) and it prevents any changes to table structure that require a complete table rebuild (like changing a datatype of a column)

Categories : SQL

How change date type in mysql
Try: ALTER TABLE tablename MODIFY columnname TIMESTAMP; More details here and here. Updated Simply: ALTER TABLE tablename CHANGE columnnane TIMESTAMP NOT NULL DEFAULT 'CURRENT_TIMESTAMP' More details.

Categories : Mysql

Change Cell Accessory Type?
You can do that in your -[UITableView cellForRowAtIndexPath:]. Just like an "else" for your if statement. And to reload the cell, you can just call reloadData or reloadRowsAtIndexPaths:withRowAnimation:.

Categories : IOS

R cannot change line type in a plot
It appears as if you have created tab by using as.data.frame(table(...))) or data.frame(table(...)). as.data.frame.table and data.frame(table(...)) will coerce dimnames to factor. # an example foo <- data.frame(a = sample(10,size=100,replace=TRUE),b = sample(10, size = 50, replace = TRUE)) str(data.frame(table(foo)) # 'data.frame': 100 obs. of 3 variables: # $ a : Factor w/ 10 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ... # $ b : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ... # $ Freq: int 1 2 2 2 3 0 4 0 0 0 .. str(as.data.frame(table(foo)) # 'data.frame': 100 obs. of 3 variables: # $ a : Factor w/ 10 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ... # $ b : Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ... # $ Freq: int 1 2 2

Categories : R

i want to change value of a submit type button?
$("#submit").click(function(){ $("#submit").val("Update"); }); In this code the #Submit should be unique in the DOM. There shouldn't be any other element in the DOM with id submit. If there exists such an element the code will show irregularity. I suspect that there may be more than one id=submit. try below code. <input type="submit" id="submitButtonOne" value="Save" /> $("#submitButtonOne").click(function(){ $("#submitButtonOne").val("Update"); }); EDIT: If your button is rendering dynamically try this $(document).ready(function(){ $('body').on('click','#submitButtonOne',function(){ $(this).val("Update"); }) }); make sure that you have loaded jquery library.

Categories : Java

Change folder name if it contains file type
The following script will list all folders within a directory tree that contain at least one *.bz2 file: @echo off setlocal set "root=d: est" for /r "%root%" %%A in (.) do if exist "%%A*.bz2" echo %%~fA You didn't state how you want to rename the folders, so you will have to figure out how to modify the above to do the rename.

Categories : Windows

Spring and persistence.xml
Long story short, JPA's EntityManagerFactory will scan your classpath for classes decorated with @Entity annotation. JPQL queries will be translated into native SQL queries based on metadata (fields) of these classes.

Categories : Spring

GAE and JPA persistence exception
The error message seems very clear The URL "file:/Applications/Eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.8.2/appengine-java-sdk-1.8.2/lib/opt/user/datanucleus/v2/datanucleus-api-jpa-3.1.3.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/Stefano/.m2/repository/org/datanucleus/datanucleus-api-jpa/3.1.3/datanucleus-api-jpa-3.1.3.jar." so suggest you put a single version of a jar in the CLASSPATH, otherwise you will get class loading problems.

Categories : Google App Engine

Persistence c#, Between two runs
You could save it in the configuration file, or you could save it in the registry. You can do both... You only have to choose. I don't like very much the registry, so I normally use the configuration file. Here there is the MSDN page that explain how to use Settings in C#.

Categories : C#

db.properties vs persistence.xml which one is better?
I assume, from the fact that you mention JSF, that you are building a web application for deployment to an application server. I also caveat this question in that I don't know about db.properties or where it comes from. When deploying to an application server, it is always best to configure your database connections in the container and expose them to the application via JNDI. This allows the container to manage connection pooling and credentials and keeps this information out of your WAR/EAR files. It also ensures that your WAR/EAR files are agnostic to the particular database instance, so can be deployed to a container in any environment without modification. Therefore, I recommend against configuring your datasource in persistence.xml. See also Difference between configuring data sou

Categories : Java

Persistence of a QMultihash
There is no standard way to do it, especially for arbitrary key and value types. Here is an example of how you can convert QMultiHash<int, double> to QVariant and back: QVariant convert(QMultiHash<int, double> hash) { QVariantList variant_hash; for(QMultiHash<int, double>::Iterator it = hash.begin(); it != hash.end(); ++it) { QVariantList list; list << it.key(); list << it.value(); variant_hash << QVariant(list); } return variant_hash; } QMultiHash<int, double> convert_back(QVariant variant_hash) { QMultiHash<int, double> new_hash; foreach(QVariant item, variant_hash.toList()) { new_hash.insertMulti(item.toList()[0].toInt(), item.toList()[1].toDouble()); } return new_hash; } It stores each item of the

Categories : C++

How to change HashMap value type from Object to String?
If you know the types of key and value (like <String, String>), you can just cast the whole map: Map<String, String> newMap = (HashMap<String, String>)oldMap; If you need a separate Map instance, you can use the constructor of HashMap like this: HashMap<String, String> = new HashMap<String, String>((HashMap<String, String>) oldMap);

Categories : Java

Highchart dynamically change the xAxis type
Did you check www.highcharts.com/errors/10? It says: Highcharts Error #10 Can't plot zero or subzero values on a logarithmic axis This error occurs in the following situations: If a zero or subzero data value is added to a logarithmic axis If the minimum of a logarithimic axis is set to 0 or less If the threshold is set to 0 or less

Categories : Highcharts



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.