Friday, April 19, 2019

mat-form-field must contain a MatFormFieldControl.


Hi Guys ,



Today I have faced this error :

ERROR Error: mat-form-field must contain a MatFormFieldControl.

Later I have found out that I have missed to add the attribute matInput .

<mat-form-field>
<input type="text" name="name" ngModel #refName="ngModel" name="name" required >
</mat-form-field>

Once I added the attribute to the input field matInput , the error was resolved .

<mat-form-field>
<input matInput type="text" name="name" ngModel #refName="ngModel" name="name" required >
</mat-form-field>


Video Link :

Full stack trace is as below .

CustDetailComponent.html:4 ERROR Error: mat-form-field must contain a MatFormFieldControl.
    at getMatFormFieldMissingControlError (form-field.es5.js:119)
    at MatFormField.push../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField._validateControlChild (form-field.es5.js:771)
    at MatFormField.push../node_modules/@angular/material/esm5/form-field.es5.js.MatFormField.ngAfterContentInit (form-field.es5.js:453)
    at callProviderLifecycles (core.js:9553)
    at callElementProvidersLifecycles (core.js:9534)
    at callLifecycleHooksChildrenFirst (core.js:9524)
    at checkAndUpdateView (core.js:10455)
    at callViewAction (core.js:10692)
    at execComponentViewsAction (core.js:10634)
    at checkAndUpdateView (core.js:10457)

oracle plsql interview questions

Important Oracle PL SQL interview Questions .

  •  What is oracle database ?
 A database is a set of physical files on disk created by the CREATE DATABASE statement .

  • What is a database instance ?
A database instance is a set of memory structures that manage database files

What is a record type.
Group of related data items stored in fields.

What is a collection type
Ordered group of elements all of same type


What is type ref cursor
Data type whose value is in memory address of query work area of the database
  • What is an index ?
By creating an index on one or more columns of a table, you gain the ability in some cases to retrieve a small set of randomly distributed rows from the table .
  • What are triggers ?
triggers are procedures stored in PL/SQL or Java that run (fire) implicitly whenever a table or view is modified or when some user actions or database system actions occur.

  1. DML
  2. DDL


  • Implicit attributes of Cursor
  1. %FOUND
  2. %ISOPEN
  3. %NOTFOUND
  4. %ROWCOUNT
        • What is a DB Link ?
        it is a schema object in one database that enables you to access objects on another database .


        •  What is a cluster ?

         A cluster is a schema object that contains data from one or more tables, all of which have one or more columns in common
        • What is a tablespace? 
        it is an allocation of space in the database that can contain schema objects.
        Types of tablespace .
        1. permanent tablespace contains persistent schema objects. Objects in permanent tablespaces are stored in datafiles.
        2. An undo tablespace is a type of permanent tablespace used by Oracle Database to manage undo data if you are running your database in automatic undo management mode. Oracle strongly recommends that you use automatic undo management mode rather than using rollback segments for undo.
        3. temporary tablespace contains schema objects only for the duration of a session. Objects in temporary tablespaces are stored in tempfiles.
        • What is SQL*Plus ?
        SQL*Plus has a command-line user interface that acts as the client when connecting to the database.
        • What is sql loader ?
        SQL*Loader is a bulk loader utility used for moving data from external files into the Oracle database.


        • Explain normalization.

        Normalization is a process of organizing the data in database to avoid data redundancy, insertion anomaly, update anomaly & deletion anomaly.
        Terminology :
        1. attribute : column
        2. candidate key : primary key ( simple or composite )
        3. prime attribute : column which is part of primary key
        4. non prime attribute : column not part of primary key .
        5. super key : any set of attributes which identifies a unique record .
        6. functional dependency : B depends on A 
        7. transitive dependency : B is dependent of A . C is dependent of B . So C has a transitive dependency on A .

        1NF : attribute should be atomic.
        2NF : non prime attribute should not depend on a subset of primary key
        3NF : non prime attribute should not have transitive dependency with the super key .
        BCNF : any functional dependency should be a super key .

        Saturday, April 13, 2019

        Angular Quiz



        Score :
        0
        Test your understanding
        angular-cli.json was deprecated in which version ?
        v5
        v4
        v6
        v7
        Info

        Sunday, March 31, 2019

        core.js:1673 ERROR Error: Uncaught (in promise): TypeError: instance[output.propName].subscribe is not a function

        Hi Guys ,



        Today I have faced this error :

        core.js:1673 ERROR Error: Uncaught (in promise): TypeError: instance[output.propName].subscribe is not a function

        Later I have found out that I have imported the EventEmitter from a different package in my component file :

        import { EventEmitter } from 'events';


        Later when I changed the package to @angular/core it worked fine .


        import { EventEmitter } from '@angular/core';

        The full stack trace is below for your reference :





        ERROR Error: Uncaught (in promise): TypeError: instance[output.propName].subscribe is not a function
        TypeError: instance[output.propName].subscribe is not a function
            at createDirectiveInstance (core.js:9183)
            at createViewNodes (core.js:10399)
            at callViewAction (core.js:10715)
            at execComponentViewsAction (core.js:10634)
            at createViewNodes (core.js:10427)
            at createRootView (core.js:10313)
            at callWithDebugContext (core.js:11344)
            at Object.debugCreateRootView [as createRootView] (core.js:10831)
            at ComponentFactory_.push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create (core.js:8659)
            at ComponentFactoryBoundToModule.push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create (core.js:3311)
            at resolvePromise (zone.js:831)
            at resolvePromise (zone.js:788)
            at zone.js:892
            at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
            at Object.onInvokeTask (core.js:3811)
            at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
            at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
            at drainMicroTaskQueue (zone.js:601)
        defaultErrorLogger @ core.js:1673
        push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:1719
        next @ core.js:4311
        schedulerFn @ core.js:3551
        push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:196
        push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:134
        push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next @ Subscriber.js:77
        push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:54
        push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next @ Subject.js:47
        push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit @ core.js:3535
        (anonymous) @ core.js:3842
        push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
        push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150
        push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:3779
        onHandleError @ core.js:3842
        push../node_modules/zone.js/dist/zone.js.ZoneDelegate.handleError @ zone.js:395
        push../node_modules/zone.js/dist/zone.js.Zone.runGuarded @ zone.js:164
        _loop_1 @ zone.js:694
        api.microtaskDrainDone @ zone.js:703
        drainMicroTaskQueue @ zone.js:608
        Promise.then (async)
        scheduleMicroTask @ zone.js:584
        push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:413
        push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:238
        push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:258
        scheduleResolveOrReject @ zone.js:879
        ZoneAwarePromise.then @ zone.js:1012
        push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:4345
        ./src/main.ts @ main.ts:11
        __webpack_require__ @ bootstrap:76
        0 @ main.ts:12
        __webpack_require__ @ bootstrap:76
        checkDeferredModules @ bootstrap:43
        webpackJsonpCallback @ bootstrap:30
        (anonymous) @ main.js:1










        Saturday, March 30, 2019

        ERROR Error: Uncaught (in promise): Error: Cannot match any routes.


        Hi Guys ,

        Today I have faced this error :

        ERROR Error: Uncaught (in promise): Error: Cannot match any routes. 

        We will face this error when we enter the URL of the angular app and the URL does not have a matching route configured . To verify that check your AppModule or AppRoutingModule . 

        1. check the router array :


        const appRoutes:Routes =[
        {path:'cust-detail',component: CustDetailComponent},
        {path:'mcq',component: MCQComponent},
        {path:'sign-up',component: SignUpComponent}
        ];


        if the path is missing add to it .

        2. check the import array :
        imports: [
        BrowserModule,
          FormsModule,
          ReactiveFormsModule,
          RouterModule.forRoot(appRoutes),
        ],

        You need to have the RouterModule.forRoot(appRoutes) present in your application.

        The full stack trace is below for your reference :


        ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'test'
        Error: Cannot match any routes. URL Segment: 'test'
            at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1384)
            at CatchSubscriber.selector (router.js:1365)
            at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:34)
            at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
            at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
            at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
            at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
            at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
            at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
            at TapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (tap.js:61)
            at resolvePromise (zone.js:831)
            at resolvePromise (zone.js:788)
            at zone.js:892
            at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
            at Object.onInvokeTask (core.js:3811)
            at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
            at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
            at drainMicroTaskQueue (zone.js:601)

        Thursday, March 21, 2019

        Web services Interview Questions

        Web Services Interview Questions.
        This blog is just for revision.
        • What is SOAP Web Services
        SOAP ( simple object access protocol) based web services (application exchange information over network)  .
        • What is Contract first ?
        WSDL or XSD is created first , then the java classes .

        • What is WSDL ?
        WS Description Language , it describes a web service .
        • What are the parts of wsdl ?
        1. types : data types used 
        2. message : request and response
        3. portType : operations available
        4. binding : 
        5. Operations:
        6. Service :
        Types
        Schema
        Contract namespace
        Schema location xsd

        Message can be multiple
        Part
        Name
        Element
        Type


        Port type
        Operation
        Input, output,fault



        Binding
        Style document/ RPC transport
        Operation
        Input
        Header, body
        Output
        Header,body
        Fault
        Fault


        Service
        Port
        Binding
        Location
        • What is XSD ?
        It defines schema which defines structure of xml.


        • Explain wsdl2java

        Use pluggin cfx-codegen-pluggin
        Goal wsdl2java
        Wsdl location
        Binding files
        Note : wsdl will have xsd,a java class for each xsd will be generated.



        • What are the elements of soap message?


        1. Envelope
        2. Header
        3. Body
        4. Fault


        •  What are SOLID principles in Rest Web services Development ?
        1. Single Responsibility : Each class has only one function 
        2. Open for Extension Closed for Modification : existing classes should not be modified , instead new classes should be created .
        3. Liskov Substitution Principle :  App should work fine if we substitute subclass in place of super class .
        4. Interface Segregation : large interfaces should be divided into smaller ones .
        5. Dependency Inversion : loose coupling .

        Wednesday, March 20, 2019

        Hibernate interview questions

        This blog is just for revision .
        • What is ORM ?
        Object Relational Mapping : Object to database tables .
        • Explain Core Classes in hibernate .
        1. Configuration : load xml file .
        2. SessionFactory : thread safe
        3. Session : get connection with database , not thread safe , used to perform CRUD operations .
        4. Transaction :  commit and rollback operations . unit of work.
        5. Query : common query language for any type of database.
        6. Criteria : add restrictions and projections
        • Explain Hibernate configuration file 
        contains database details used to initialize session factory .

        • Explain Hibernate Mapping file 
        contains table and column details also contains the entity bean mapping .

        • Explain state of the entity in the persistence context .
        Session is the persistence context which is used to manage relationship of the entities .
        1. transient : newly created object 
        2. persistent : associated with session ( session.save)
        3. detached : session closed 
        • How to use hibernate in spring ?
        In application context.xml file specify

        1. the datasource bean  DriverManagerDataSource  
          • specify the username /password or jndi
        2. sessionfactory bean LocalSessionFactoryBean
        3. transaction bean HibernateTransactionManager
        4. tx:annotation driven 
        • What is hibernate dialect.
        Different dialect for different databases
        MySqlDialect , Oracle Dialect ,Db2 Dialect.


        • What are the different consistency anomalies in hibernate .
        1. dirty read .reading uncommitted data
        2. non repeatable read : second read returns different values for a row
        3. phantom read : second read returns different number of rows 

        • Explain isolation level .
        1. Read uncommitted
        2. Read committed :  
              4. Repeatable Read : second read will return same value 
              8. synchronized : does not allow concurrency

        Isolation level is set using property hibernate.connection.isolation 


        • Explain the locking strategy based on isolation level .
        1. Read uncommitted : no lock 
        2. Read committed : lock on committed data
              4. Repeatable Read : lock on a block of  SQL
              8. Synchronized : full lock on table .

        • In which scenario repeatable read will return different data .
        If the read is based on a condition and another thread inserts a row in database . Now for the second read we may get the new also if it satisfies the condition .
        • What is Caching in hibernate ?
        1. First level Catch : session cache of hibernate , enabled by default 
        2. Second Level Cache : optional , eg : Ehcache 
        3. Query Level Cache : cached query results . set hibernate.cache.use_query_cache property to true
        • What are the concurrency strategies for second level cache?
        1. Transactional : synchronized with the database .
        2. Read-write : if the transaction is not committed , the entity is fetched from database and referred from the cache .
        3. non strict read write : cache updated after data committed
        4. read only : used when data never gets changed .

        • What is dirty checking?

        When hibernate loads an entity it keeps a copy of it in the memory, on tx.commit it compares the entity and the copy . If there are any changes, update statement is executed in the database.
        • Explain session.get
        1. Hits the database immediately.
        2. If record is not available in the database it returns null.
        • Explain session.load
        1. Returns proxy object without hitting the database.
        2. If the record is not available and when we try to access it through the proxy object we get Object Not Found Exception.
        • What is the difference between get and load ?
        in case of no records in the database get returns null and load throws an exception .
        • What is the difference between save and persist ?
        save return the id and persists returns nothing .persist marks the entity as persistent , does not generate Insert statement outside transaction boundaries . session.save on detached object will create a new row , session.persist on detached object will throw persistentobjectexception.

        What is the difference between session.save and session.saveorupdate
        save will insert the record if the Id is not available and throw exception if the Id is available. Saveorupdate will insert the record if the Id is not available, else it will update it.


        • What is the difference between update and merge ?
        Update is used to update the persistent entity and Merge is used to update a detached entity .
        • What is the difference between session.flush and transaction.commit ?
        flush synchronizes the persistent store with the state held  in memory .
        commit commits the record to the database .
        • Explain Criteria
        Used to filter record
        cr =Session.createCriteria
        cr.list();

        • Explain Restrictions
        Used to add condition s to the query to compare the columns
        Cr.add( Restrictions.eq("id" , 10));
        • Explain Projections
        Used to call an aggregate method . Min , max , count .
        Cr.setProjection( Projections.max("id"));

        • What is Declarative transaction management  ?
         transaction handling is not a part of business logic . 
        using @Transactional :
        • What is Programmatic transaction management ?
        transaction management is a part of business logic . 

        • Explain Different transaction manager used in spring .
        1. DataSourceTransactionManager : uses datasource 
        2. HibernateTransactionManager : uses sessionfactory
        3. JpaTransactionManager : uses entitiymanagerfactory 
        • Explain transaction propagation ?
        using @Transactional( propagation=Propagation.
        1. REQUIRED : (default) if transaction is available use it otherwise create a new one. 
        2. REQUIRES_NEW : create a new transaction , commit / rollback is independent .
        3. NESTED : uses outer transaction but creates a savepoint to allow partial rollback and commit .

        • What is readOnly in @Transactional ?
        used for only read operations
        • What are Value Types .
        1. Basic 
        2. Composite / Embedded
        3. Collection : for one to many .
        • Explain Many to Many .
        Tables : Person , Project, PersonProject 
        Entities :
        Person : on projects set attribute add
        1. @ManyToMany 
        2. @JoinTable ( name=PersonProject , joinColums=@JoinColum , inverseJoinColumns=@JoinColum  )
        Project: on persons set attribute add

        1.  @ManyToMany(mappedBy = "projects")


        • Explain One to Many
        Tables : Person , Address

        Entities :

        •   Explain Cascade type :
        In case of mapping like one to one,or one to many , cascade type defines how changes in the entity will cascade to the mapped entity .
        @ oneToMany cascade = Cascade Type.ALL
        1. All
        2. Persist
        3. Merge
        4. Refresh
        5. Remove
        6. Detach

        • How to lazy load the mapped classes

        @oneToMany fetch = Fetch type.Lazy


        • What are the fetching strategies ?
        1. Join Fetching 
        2. Select Fetching 
        3. Sub select Fetching 
        4. Batch Fetching 

        • How to handle multiple databases ?
        1. @Table (schema= "")
        2. create two sessionfactory , use @Qualifier
        • How to handle distributed databases ?
        use XA datasource , if  transaction is failed in one database , the entire transaction is roll backed .


        • What is the difference between jdbc and JTA?

        2 phase commit can be handled using JTA only .

        •  Explain different ways of creating  EntityManager ?
        1. Container Managed : 
        @PersistenceContext
        EntityManager entityManager; 

        2. Application Managed 
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.model.student");
        • Explain  Anomalies in DBMS

        1. Update : multiple rows needs to be updated to update a data .

        2. Insert : cannot insert a row without supplementary data.

        3. Delete : unable to delete a data as this will cause the important information to be deleted.



        • Explain normalization.

        Normalization is a process of organizing the data in database to avoid data redundancy, insertion anomaly, update anomaly & deletion anomaly.
        Terminology :
        1. attribute : column
        2. candidate key : primary key ( simple or composite )
        3. prime attribute : column which is part of primary key
        4. non prime attribute : column not part of primary key .
        5. super key : any set of attributes which identifies a unique record .
        6. functional dependency : B depends on A 
        7. transitive dependency : B is dependent of A . C is dependent of B . So C has a transitive dependency on A .

        1NF : attribute should be atomic.
        2NF : non prime attribute should not depend on a subset of primary key
        3NF : non prime attribute should not have transitive dependency with the super key .
        BCNF : any functional dependency should be a super key .

        ec2-user@ec2 Permission denied